diff --git a/install/install.php b/install/install.php
index 4437bd8fa387e0407271c4c79df27fb1282e1ec7..ef8264169a2a6950c7f138d412ec32bf0b1267ea 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 :-)
 $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y';
 if($install_mode == 'standard' || strtolower($inst->simple_query('Install ISPConfig Web Interface', array('y', 'n'), $install_ispconfig_interface_default,'install_ispconfig_web_interface')) == 'y') {
@@ -572,8 +580,9 @@ if($install_mode == 'standard' || strtolower($inst->simple_query('Install ISPCon
 
 // Create SSL certs for non-webserver(s)?
 if(!file_exists('/usr/local/ispconfig/interface/ssl/ispserver.crt')) {
-    if(strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y')
+    if(strtolower($inst->simple_query('Do you want to create SSL certs for your server?', array('y', 'n'), 'y')) == 'y') {
         $inst->make_ispconfig_ssl_cert();
+	}
 } else {
 	swriteln('Certificate exists. Not creating a new one.');
 }
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 9ac5c788f0f7169527c6b096e757a40738e607b8..efb161569dc2d0f29d927117c282fd2d400fbc33 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() {
@@ -2893,15 +2890,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;
@@ -2999,9 +3003,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(($svr_ip4 && in_array($svr_ip4, $dns_ips)) || ($svr_ip6 && in_array($svr_ip6, $dns_ips))) {
 				// 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 1b6331f7da289babdf0115aab4c8405a3291a942..3107adbb62e517192e918c89e90e27e7b7b176a5 100644
--- a/install/update.php
+++ b/install/update.php
@@ -519,6 +519,14 @@ if($reconfigure_services_answer == 'yes' || $reconfigure_services_answer == 'sel
 //** Configure ISPConfig
 swriteln('Updating ISPConfig');
 
+// 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();