autodetect correct php version and adjust configs as needed
This commit is contained in:
parent
c68942f0aa
commit
48871ee4fd
|
@ -57,7 +57,7 @@ if /bin/grep -q "^$username:" /etc/passwd; then
|
|||
if [[ -n "$fpmmax" ]]; then
|
||||
vhost::set-phpVersion
|
||||
if [[ -f /etc/php/$phpVersion/fpm/pool.d/$username.conf ]]; then
|
||||
sed -i "s|pm.max_children.*|pm.max_children = $fpmmax|g" /etc/php/8.1/fpm/pool.d/$username.conf
|
||||
sed -i "s|pm.max_children.*|pm.max_children = $fpmmax|g" /etc/php/$phpVersion/fpm/pool.d/$username.conf
|
||||
else
|
||||
echo "ERROR: PHP config for $username does not exist."
|
||||
exit 1
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
|
||||
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
</Macro>
|
||||
|
@ -52,7 +52,7 @@
|
|||
</IfDefine>
|
||||
DocumentRoot /srv/www/$vhost/html/$subdomain
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
</Macro>
|
||||
|
@ -78,7 +78,7 @@
|
|||
</Location>
|
||||
</IfDefine>
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
|
@ -93,7 +93,7 @@
|
|||
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
|
||||
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/ssl/letsencrypt/$vhost.pem
|
||||
|
@ -129,7 +129,7 @@
|
|||
</Location>
|
||||
</IfDefine>
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
|
@ -139,7 +139,7 @@
|
|||
</IfDefine>
|
||||
DocumentRoot /srv/www/$vhost/html/$subdomain
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/ssl/letsencrypt/$subdomain.$vhost.pem
|
||||
|
@ -160,7 +160,7 @@
|
|||
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
|
||||
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
|
@ -187,7 +187,7 @@
|
|||
</IfDefine>
|
||||
DocumentRoot /srv/www/$vhost/html/$subdomain
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
|
@ -299,7 +299,7 @@
|
|||
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
|
||||
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
</Macro>
|
||||
|
@ -324,7 +324,7 @@
|
|||
</Location>
|
||||
</IfDefine>
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
<VirtualHost *:443>
|
||||
|
@ -339,7 +339,7 @@
|
|||
RewriteCond %{REQUEST_URI} ^/cgi-bin/.*
|
||||
RewriteRule ^/cgi-bin/(.*) /cgi-wrap/cgiwrap/$username/$1 [PT]
|
||||
<FilesMatch ".+\.ph(ar|p|tml)$">
|
||||
SetHandler "proxy:unix:/run/php/php8.1-fpm-$username.sock|fcgi://localhost"
|
||||
SetHandler "proxy:unix:/run/php/phpPHPVERSION-fpm-$username.sock|fcgi://localhost"
|
||||
</FilesMatch>
|
||||
SSLEngine on
|
||||
SSLCertificateFile /etc/ssl/letsencrypt/$alias.pem
|
||||
|
|
|
@ -44,6 +44,9 @@ fi
|
|||
# install systemd files and reload
|
||||
cp systemd/* /usr/local/lib/systemd/system/
|
||||
chmod 644 /usr/local/lib/systemd/system/*
|
||||
# set php version
|
||||
sed -i "s|PHPVERSION|$phpVersion|g" /usr/local/lib/systemd/system/vhost-reload-php.path
|
||||
sed -i "s|PHPVERSION|$phpVersion|g" /usr/local/lib/systemd/system/vhost-reload-php.service
|
||||
systemctl daemon-reload
|
||||
|
||||
# install pwgen, used to create random passwords
|
||||
|
@ -97,6 +100,8 @@ chown root:root /etc/apache2/mods-available/*.conf
|
|||
sed -i "s|SSLProtocol.*|SSLProtocol TLSv1.2|g" /etc/apache2/mods-available/ssl.conf
|
||||
# set vhost subodmain to domain name of server, users may want to consider changing this to a custom domain.
|
||||
sed -i "s|example.com|$vhostdomain|g" /etc/apache2/mods-available/macro.conf
|
||||
# set php version
|
||||
sed -i "s|PHPVERSION|$phpVersion|g" /etc/apache2/mods-available/macro.conf
|
||||
# a2enmod proxy_fcgi rewrite headers expires ssl http2 remoteip macro
|
||||
a2enmod cgid proxy_fcgi proxy_http rewrite headers expires ssl http2 macro
|
||||
# # sed -i "s|CustomLog|#CustomLog|g" /etc/apache2/sites-available/000-default.conf
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Description="Reload PHP-FPM on changes to pool config files"
|
||||
|
||||
[Path]
|
||||
PathChanged=/etc/php/8.1/fpm/pool.d/
|
||||
PathChanged=/etc/php/PHPVERSION/fpm/pool.d/
|
||||
Unit=vhost-reload-php.service
|
||||
|
||||
[Install]
|
||||
|
|
|
@ -4,4 +4,4 @@ Description=Reload PHP-FPM
|
|||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=sleep 2
|
||||
ExecStart=systemctl try-reload-or-restart php8.1-fpm
|
||||
ExecStart=systemctl try-reload-or-restart phpPHPVERSION-fpm
|
||||
|
|
Loading…
Reference in New Issue
Block a user