@@ -497,6 +497,7 @@ public function configure_apache()
497497 {
498498 global $ conf ;
499499
500+ if ($ conf ['apache ' ]['installed ' ] == false ) return ;
500501 if (is_file ('/etc/suphp.conf ' )) {
501502 //replaceLine('/etc/suphp.conf','php=php:/usr/bin','x-httpd-suphp=php:/usr/bin/php-cgi',0);
502503 replaceLine ('/etc/suphp.conf ' ,'docroot= ' ,'docroot=/var/www ' ,0 );
@@ -741,6 +742,8 @@ public function install_ispconfig()
741742 if (is_dir ($ dir )) {
742743 if ($ dh = opendir ($ dir )) {
743744 while (($ file = readdir ($ dh )) !== false ) {
745+ if ($ conf ['apache ' ]['installed ' ] == true && $ file == 'nginx_plugin.inc.php ' ) continue ;
746+ if ($ conf ['nginx ' ]['installed ' ] == true && $ file == 'apache2_plugin.inc.php ' ) continue ;
744747 if ($ file != '. ' && $ file != '.. ' && substr ($ file ,-8 ,8 ) == '.inc.php ' ) {
745748 include_once ($ install_dir .'/server/plugins-available/ ' .$ file );
746749 $ plugin_name = substr ($ file ,0 ,-8 );
@@ -822,55 +825,100 @@ public function install_ispconfig()
822825 $ command = "chmod +x $ install_dir/server/scripts/*.sh " ;
823826 caselog ($ command .' &> /dev/null ' , __FILE__ , __LINE__ , "EXECUTED: $ command " , "Failed to execute the command $ command " );
824827
825- //* Copy the ISPConfig vhost for the controlpanel
826- // TODO: These are missing! should they be "vhost_dist_*_dir" ?
827- $ vhost_conf_dir = $ conf ['apache ' ]['vhost_conf_dir ' ];
828- $ vhost_conf_enabled_dir = $ conf ['apache ' ]['vhost_conf_enabled_dir ' ];
828+ if ($ conf ['apache ' ]['installed ' ] == true ){
829+ //* Copy the ISPConfig vhost for the controlpanel
830+ // TODO: These are missing! should they be "vhost_dist_*_dir" ?
831+ $ vhost_conf_dir = $ conf ['apache ' ]['vhost_conf_dir ' ];
832+ $ vhost_conf_enabled_dir = $ conf ['apache ' ]['vhost_conf_enabled_dir ' ];
829833
830834
831- // Dont just copy over the virtualhost template but add some custom settings
832- $ content = rf ("tpl/apache_ispconfig.vhost.master " );
833- $ content = str_replace ('{vhost_port} ' , $ conf ['apache ' ]['vhost_port ' ], $ content );
835+ // Dont just copy over the virtualhost template but add some custom settings
836+ $ content = rf ("tpl/apache_ispconfig.vhost.master " );
837+ $ content = str_replace ('{vhost_port} ' , $ conf ['apache ' ]['vhost_port ' ], $ content );
838+
839+ // comment out the listen directive if port is 80 or 443
840+ if ($ conf ['apache ' ]['vhost_port ' ] == 80 or $ conf ['apache ' ]['vhost_port ' ] == 443 ) {
841+ $ content = str_replace ('{vhost_port_listen} ' , '# ' , $ content );
842+ } else {
843+ $ content = str_replace ('{vhost_port_listen} ' , '' , $ content );
844+ }
834845
835- // comment out the listen directive if port is 80 or 443
836- if ($ conf ['apache ' ]['vhost_port ' ] == 80 or $ conf ['apache ' ]['vhost_port ' ] == 443 ) {
837- $ content = str_replace ('{vhost_port_listen} ' , '# ' , $ content );
838- } else {
839- $ content = str_replace ('{vhost_port_listen} ' , '' , $ content );
840- }
846+ if (is_file ('/usr/local/ispconfig/interface/ssl/ispserver.crt ' ) && is_file ('/usr/local/ispconfig/interface/ssl/ispserver.key ' )) {
847+ $ content = str_replace ('{ssl_comment} ' , '' , $ content );
848+ } else {
849+ $ content = str_replace ('{ssl_comment} ' , '# ' , $ content );
850+ }
841851
842- if (is_file ('/usr/local/ispconfig/interface/ssl/ispserver.crt ' ) && is_file ('/usr/local/ispconfig/interface/ssl/ispserver.key ' )) {
843- $ content = str_replace ('{ssl_comment} ' , '' , $ content );
844- } else {
845- $ content = str_replace ('{ssl_comment} ' , '# ' , $ content );
846- }
852+ wf ("$ vhost_conf_dir/ispconfig.vhost " , $ content );
847853
848- wf ("$ vhost_conf_dir/ispconfig.vhost " , $ content );
854+ //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
855+ //* and create the symlink
856+ if ($ this ->install_ispconfig_interface == true && $ this ->is_update == false ) {
857+ if (@is_link ("$ vhost_conf_enabled_dir/ispconfig.vhost " )) unlink ("$ vhost_conf_enabled_dir/ispconfig.vhost " );
858+ if (!@is_link ("$ vhost_conf_enabled_dir/000-ispconfig.vhost " )) {
859+ exec ("ln -s $ vhost_conf_dir/ispconfig.vhost $ vhost_conf_enabled_dir/000-ispconfig.vhost " );
860+ }
861+
862+ exec ('mkdir -p /var/www/php-fcgi-scripts/ispconfig ' );
863+ exec ('cp tpl/apache_ispconfig_fcgi_starter.master /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter ' );
864+ exec ('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter ' );
865+ exec ('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig ' );
866+ exec ('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig ' );
867+
868+ replaceLine ('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter ' ,'PHPRC= ' ,'PHPRC=/etc/ ' ,0 ,0 );
869+ }
849870
850- //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
851- //* and create the symlink
852- if ($ this ->install_ispconfig_interface == true && $ this ->is_update == false ) {
853- if (@is_link ("$ vhost_conf_enabled_dir/ispconfig.vhost " )) unlink ("$ vhost_conf_enabled_dir/ispconfig.vhost " );
854- if (!@is_link ("$ vhost_conf_enabled_dir/000-ispconfig.vhost " )) {
855- exec ("ln -s $ vhost_conf_dir/ispconfig.vhost $ vhost_conf_enabled_dir/000-ispconfig.vhost " );
871+ //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
872+ //* and create the symlink
873+ if ($ this ->install_ispconfig_interface == true && $ this ->is_update == false ) {
874+ if (@is_link ("$ vhost_conf_enabled_dir/ispconfig.vhost " )) unlink ("$ vhost_conf_enabled_dir/ispconfig.vhost " );
875+ if (!@is_link ("$ vhost_conf_enabled_dir/000-ispconfig.vhost " )) {
876+ exec ("ln -s $ vhost_conf_dir/ispconfig.vhost $ vhost_conf_enabled_dir/000-ispconfig.vhost " );
877+ }
878+ }
879+ }
880+
881+ if ($ conf ['nginx ' ]['installed ' ] == true ){
882+ //* Copy the ISPConfig vhost for the controlpanel
883+ $ vhost_conf_dir = $ conf ['nginx ' ]['vhost_conf_dir ' ];
884+ $ vhost_conf_enabled_dir = $ conf ['nginx ' ]['vhost_conf_enabled_dir ' ];
885+
886+ // Dont just copy over the virtualhost template but add some custom settings
887+ $ content = rf ('tpl/nginx_ispconfig.vhost.master ' );
888+ $ content = str_replace ('{vhost_port} ' , $ conf ['nginx ' ]['vhost_port ' ], $ content );
889+
890+ if (is_file ($ install_dir .'/interface/ssl/ispserver.crt ' ) && is_file ($ install_dir .'/interface/ssl/ispserver.key ' )) {
891+ $ content = str_replace ('{ssl_on} ' , ' ssl ' , $ content );
892+ $ content = str_replace ('{ssl_comment} ' , '' , $ content );
893+ $ content = str_replace ('{fastcgi_ssl} ' , 'on ' , $ content );
894+ } else {
895+ $ content = str_replace ('{ssl_on} ' , '' , $ content );
896+ $ content = str_replace ('{ssl_comment} ' , '# ' , $ content );
897+ $ content = str_replace ('{fastcgi_ssl} ' , 'off ' , $ content );
856898 }
857899
858- exec ('mkdir -p /var/www/php-fcgi-scripts/ispconfig ' );
859- exec ('cp tpl/apache_ispconfig_fcgi_starter.master /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter ' );
860- exec ('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter ' );
861- exec ('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig ' );
862- exec ('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig ' );
900+ $ content = str_replace ('{fpm_port} ' , $ conf ['nginx ' ]['php_fpm_start_port ' ], $ content );
901+
902+ wf ($ vhost_conf_dir .'/ispconfig.vhost ' , $ content );
863903
864- replaceLine ( ' /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter ' , ' PHPRC= ' , ' PHPRC=/etc/ ' , 0 , 0 );
904+ unset( $ content );
865905
866- }
867-
868- //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
869- //* and create the symlink
870- if ($ this ->install_ispconfig_interface == true && $ this ->is_update == false ) {
871- if (@is_link ("$ vhost_conf_enabled_dir/ispconfig.vhost " )) unlink ("$ vhost_conf_enabled_dir/ispconfig.vhost " );
872- if (!@is_link ("$ vhost_conf_enabled_dir/000-ispconfig.vhost " )) {
873- exec ("ln -s $ vhost_conf_dir/ispconfig.vhost $ vhost_conf_enabled_dir/000-ispconfig.vhost " );
906+ // PHP-FPM
907+ // Dont just copy over the php-fpm pool template but add some custom settings
908+ $ content = rf ('tpl/php_fpm_pool.conf.master ' );
909+ $ content = str_replace ('{fpm_pool} ' , 'ispconfig ' , $ content );
910+ $ content = str_replace ('{fpm_port} ' , $ conf ['nginx ' ]['php_fpm_start_port ' ], $ content );
911+ $ content = str_replace ('{fpm_user} ' , 'ispconfig ' , $ content );
912+ $ content = str_replace ('{fpm_group} ' , 'ispconfig ' , $ content );
913+ wf ($ conf ['nginx ' ]['php_fpm_pool_dir ' ].'/ispconfig.conf ' , $ content );
914+
915+ //copy('tpl/nginx_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
916+ //* and create the symlink
917+ if ($ this ->install_ispconfig_interface == true && $ this ->is_update == false ) {
918+ if (@is_link ($ vhost_conf_enabled_dir .'/ispconfig.vhost ' )) unlink ($ vhost_conf_enabled_dir .'/ispconfig.vhost ' );
919+ if (!@is_link ($ vhost_conf_enabled_dir .'/000-ispconfig.vhost ' )) {
920+ symlink ($ vhost_conf_dir .'/ispconfig.vhost ' ,$ vhost_conf_enabled_dir .'/000-ispconfig.vhost ' );
921+ }
874922 }
875923 }
876924
0 commit comments