diff --git a/install/install.php b/install/install.php
index ee455dbca8af3bdf555b9e26c0df05ce7e8a4914..cdf6806092be0f2d5f81db3468a4e9e8bdb702b8 100644
--- a/install/install.php
+++ b/install/install.php
@@ -536,6 +536,14 @@ if($force) {
 	$inst->configure_fail2ban();
 }
 
+// create acme vhost
+if($conf['nginx']['installed'] == true) {
+	$inst->make_acme_vhost('nginx'); // we need this config file but we don't want nginx to be restarted at this point
+}
+if($conf['apache']['installed'] == true) {
+	$inst->make_acme_vhost('apache'); // we need this config file but we don't want apache to be restarted at this point
+}
+
 //** Configure ISPConfig :-)
 $issue_tried = false;
 $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y';
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index f07eadff71fff208a385002da2c8ae067ef4bf16..9aa48a79750aef90d8814aede028c0e93975de9f 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -2721,9 +2721,15 @@ class installer_base {
 		return $response;
 	}
 
-	private function make_acme_vhost($server_name, $server = 'apache', $restart = true) {
+	private function make_acme_vhost($server = 'apache') {
 		global $conf;
 
+		if($conf['hostname'] !== 'localhost' && $conf['hostname'] !== '') {
+			$server_name = $conf['hostname'];
+		} else {
+			$server_name = exec('hostname -f');
+		}
+
 		$use_template = 'apache_acme.conf.master';
 		$use_symlink = '999-acme.conf';
 		$use_name = 'acme.conf';
@@ -2759,15 +2765,6 @@ class installer_base {
 		if(!@is_link($vhost_conf_enabled_dir.'' . $use_symlink)) {
 			symlink($vhost_conf_dir.'/' . $use_name, $vhost_conf_enabled_dir.'/' . $use_symlink);
 		}
-		if($restart === true) {
-			if($conf[$server]['installed'] == true && $conf[$server]['init_script'] != '') {
-				if($this->is_update) {
-					system($this->getinitcommand($conf[$server]['init_script'], 'force-reload').' &> /dev/null || ' . $this->getinitcommand($conf[$server]['init_script'], 'restart').' &> /dev/null');
-				} else {
-					system($this->getinitcommand($conf[$server]['init_script'], 'restart').' &> /dev/null');
-				}
-			}
-		}
 	}
 
 	public function make_ispconfig_ssl_cert() {
@@ -2899,15 +2896,22 @@ class installer_base {
 			// first of all create the acme vhosts if not existing
 			if($conf['nginx']['installed'] == true) {
 				swriteln('Using nginx for certificate validation');
-				$this->make_acme_vhost($hostname, 'nginx');
+				$server = 'nginx';
 			} elseif($conf['apache']['installed'] == true) {
 				swriteln('Using apache for certificate validation');
 				if($this->is_update == false && @is_link($vhost_conf_enabled_dir.'/000-ispconfig.conf')) {
 					$restore_conf_symlink = true;
 					unlink($vhost_conf_enabled_dir.'/000-ispconfig.conf');
 				}
+				$server = 'apache';
+			}
 
-				$this->make_acme_vhost($hostname, 'apache');
+			if($conf[$server]['installed'] == true && $conf[$server]['init_script'] != '') {
+				if($this->is_update) {
+					system($this->getinitcommand($conf[$server]['init_script'], 'force-reload').' &> /dev/null || ' . $this->getinitcommand($conf[$server]['init_script'], 'restart').' &> /dev/null');
+				} else {
+					system($this->getinitcommand($conf[$server]['init_script'], 'restart').' &> /dev/null');
+				}
 			}
 
 			$issued_successfully = false;
@@ -3005,9 +3009,6 @@ class installer_base {
 				}
 			}
 		} else {
-			if($conf['apache']['installed'] == true) {
-				$this->make_acme_vhost($hostname, 'apache', false); // we need this config file but we don't want apache to be restarted at this point
-			}
 			if($ip_address_match) {
 				// the directory already exists so we have to assume that it was created previously
 				$issued_successfully = true;
diff --git a/install/update.php b/install/update.php
index 517f78cf4f8051dcc2f3488a64e7e34b3b81bc30..75be8a46ccaf72fef45e4b87890b68d3e371899a 100644
--- a/install/update.php
+++ b/install/update.php
@@ -520,6 +520,14 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel
 swriteln('Updating ISPConfig');
 
 $issue_tried = false;
+// create acme vhost
+if($conf['nginx']['installed'] == true) {
+	$inst->make_acme_vhost('nginx'); // we need this config file but we don't want nginx to be restarted at this point
+}
+if($conf['apache']['installed'] == true) {
+	$inst->make_acme_vhost('apache'); // we need this config file but we don't want apache to be restarted at this point
+}
+
 if ($inst->install_ispconfig_interface) {
 	//** Customise the port ISPConfig runs on
 	$ispconfig_port_number = get_ispconfig_port_number();