From 9bf70dcd58938eea6e8bc8dd8083db60e17e794c Mon Sep 17 00:00:00 2001 From: earnolmartin Date: Mon, 23 Oct 2023 15:17:57 -0600 Subject: [PATCH] Install nginx by default if passed in nginx argument --- ehcp/install_1.php | 6 +++++- ehcp/install_2.php | 11 +++++++---- ehcp/install_lib.php | 37 +++++++++++++++++++++++++++++-------- ehcp/install_main.sh | 6 ++++-- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/ehcp/install_1.php b/ehcp/install_1.php index 5d8e109..ece2062 100755 --- a/ehcp/install_1.php +++ b/ehcp/install_1.php @@ -3,6 +3,7 @@ error_reporting (E_ALL ^ E_NOTICE); // first part of install. // this installs mailserver, then, install2 begins, // i separated these installs because php email function does not work if i re-start php after email install... +$webServerToInstall = "apache2"; if($argc>1){ @@ -18,7 +19,7 @@ if($argc>1){ $distro = strtolower(trim($argv[2])); } -for($i=3;$i<=6;$i++){ # accept following arguments in any of position. +for($i=3;$i<=7;$i++){ # accept following arguments in any of position. if($argc>$i) { print "argc:$argc\n\n"; switch($argv[$i]) { @@ -38,6 +39,9 @@ for($i=3;$i<=6;$i++){ # accept following arguments in any of position. case 'debug': $debugMode = true; break; + case 'nginx': + $webServerToInstall = "nginx"; + break; default: echo __FILE__." dosyasinda bilinmeyen arguman degeri:".$argv[$i]; break; diff --git a/ehcp/install_2.php b/ehcp/install_2.php index 47eb037..43a97fa 100755 --- a/ehcp/install_2.php +++ b/ehcp/install_2.php @@ -4,6 +4,7 @@ error_reporting (E_ALL ^ E_NOTICE); // first part installs mailserver, then, install2 begins, // i separated these installs because php email function does not work if i re-start php after email install... // install functions in install_lib.php +$webServerToInstall = "apache2"; if($argc>1){ @@ -19,7 +20,7 @@ if($argc>1){ $distro = strtolower(trim($argv[2])); } -for($i=3;$i<=6;$i++){ # accept following arguments in any of position. +for($i=3;$i<=7;$i++){ # accept following arguments in any of position. if($argc>$i) { print "argc:$argc\n\n"; switch($argv[$i]) { @@ -39,6 +40,9 @@ for($i=3;$i<=6;$i++){ # accept following arguments in any of position. case 'debug': $debugMode = true; break; + case 'nginx': + $webServerToInstall = "nginx"; + break; default: echo __FILE__." dosyasinda bilinmeyen arguman degeri:".$argv[$i]; break; @@ -91,12 +95,11 @@ install_vsftpd_server(); fail2ban_install(); -if((isset($version) && $version != "12.10" && $distro == "ubuntu") || $distro == "debian"){ +if($webServerToInstall == "nginx" || ((isset($version) && $version != "12.10" && $distro == "ubuntu") || $distro == "debian")){ install_nginx_webserver(); }else{ - echo "Ubuntu 12.10 is not compatible with nginx due to bugs. Installing apache2 only. Upgrade to Ubuntu 13.04 for this functionality.\n"; + installapacheserver(); } -installapacheserver(); # scandb(); no more need to scan db since ver. 0.29.15 installfinish(); diff --git a/ehcp/install_lib.php b/ehcp/install_lib.php index 322f99b..7fa2658 100755 --- a/ehcp/install_lib.php +++ b/ehcp/install_lib.php @@ -1269,7 +1269,12 @@ function rebuild_nginx_config2($mydir){ passthru2("cp $mydir/etc/nginx/apachetemplate.nginx $mydir/apachetemplate_passivedomains"); passthru2("cp $mydir/etc/nginx/apache_subdomain_template.nginx $mydir/apache_subdomain_template"); replacelineinfile("listen =","listen = 9000","$phpConfDir/fpm/pool.d/www.conf", true); - manageService("php5-fpm", "restart"); + + $phpFPMVersion = $app->getPHPFPMName(); + if($phpFPMVersion === false){ + $phpFPMVersion = "php5-fpm"; + } + manageService($phpFPMVersion, "restart"); } function install_nginx_webserver(){ @@ -1298,14 +1303,24 @@ function install_nginx_webserver(){ copy("$mydir/etc/nginx/mime.types","/etc/nginx/mime.types"); - // Stop and disable services - manageService("php5-fpm", "stop"); - manageService("nginx", "stop"); - $app->disableService("php5-fpm"); - $app->disableService("nginx"); + $phpFPMVersion = $app->getPHPFPMName(); + if($phpFPMVersion === false){ + $phpFPMVersion = "php5-fpm"; + } - // Start apache2 - manageService("apache2", "start"); + // We're configuring the nginx server, but if the user switches to apache2 later, we need to be partially setup for it... + rebuild_apache2_config2(); + + // Ok, now go ahead and rebuild the nginx config + rebuild_nginx_config2(); + + manageService($phpFPMVersion, "restart"); + manageService("nginx", "restart"); + + // Stop and disable services + $app->disableService("apache2"); + $app->enableService("nginx"); + $app->enableService($phpFPMVersion); echo "\nEnd nginx install\n"; #bekle(); @@ -1317,6 +1332,12 @@ function installapacheserver($apacheconf=''){ #bekle(__FUNCTION__." basliyor.."); aptget(array('libapache2-mod-php5','libapache2-mod-php','php5','php')); + aptget(array('apache2')); + + // We're configuring the apache server, but if the user switches to nginx later, we need to be partially setup for it... + rebuild_nginx_config2(); + + // Ok, now go ahead and rebuild the apache config rebuild_apache2_config2(); } diff --git a/ehcp/install_main.sh b/ehcp/install_main.sh index 3f4776d..3162405 100755 --- a/ehcp/install_main.sh +++ b/ehcp/install_main.sh @@ -43,6 +43,8 @@ do skip_updates="yes" elif [ "$varCheck" == "debug" ]; then debug="debug" + elif [ "$varCheck" == "nginx" ]; then + webserver="nginx" fi done @@ -3308,7 +3310,7 @@ echo echo "STAGE 2" echo "=====================================================================" echo "now running install_1.php " -php install_1.php $version $distro $noapt $unattended $installmode $debug +php install_1.php $version $distro $noapt $unattended $installmode $debug $webserver echo echo @@ -3318,7 +3320,7 @@ echo "now running install_2.php " #Send version to avoid installing nginx on Ubuntu 12.10 --- there is a bug and it's not supported #php install_2.php $noapt || php /etc/ehcp/install_2.php $noapt # start install_2.php if first install is successfull at php level. to prevent many errors. -php install_2.php $version $distro $noapt $unattended $installmode $debug +php install_2.php $version $distro $noapt $unattended $installmode $debug $webserver ############################################### # Post Install Functions by Eric Arnol-Martin #