Skip to content

Commit

Permalink
Adding PHP 8.2 support
Browse files Browse the repository at this point in the history
As well as 8.1 and 8.0
  • Loading branch information
jonathanbossenger committed Dec 28, 2022
1 parent c842c5a commit fdd9c31
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 14 deletions.
45 changes: 31 additions & 14 deletions config/cloud-init-for-wp-local-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ runcmd:
- apt install php libapache2-mod-php php-mysql php-common php-xml php-xmlrpc php-curl php-gd php-imagick php-cli php-dev php-imap php-mbstring php-soap php-zip -y
# Enable Apache modules
- a2enmod ssl rewrite
- echo "Installing Legacy PHP"
# Install FastCGI Mod
- apt-get install libapache2-mod-fcgid
- a2enmod actions alias proxy_fcgi fcgid
# Set up PHP 8.1 using FastCGI
- apt-get install php8.1 php8.1-fpm php8.1-mysql php8.1-common php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-mbstring php8.1-soap php8.1-zip -y
- sudo systemctl start php8.1-fpm
# Set up PHP 8.0 using FastCGI
- apt-get install libapache2-mod-fcgid php8.0 php8.0-fpm php8.0-mysql php8.0-common php8.0-xml php8.0-xmlrpc php8.0-curl php8.0-gd php8.0-imagick php8.0-mbstring php8.0-soap php8.0-zip -y
- apt-get install php8.0 php8.0-fpm php8.0-mysql php8.0-common php8.0-xml php8.0-xmlrpc php8.0-curl php8.0-gd php8.0-imagick php8.0-mbstring php8.0-soap php8.0-zip -y
- sudo systemctl start php8.0-fpm
- a2enmod actions alias proxy_fcgi fcgid
- service apache2 restart
# Set up PHP 7.4 using FastCGI
- apt-get php7.4 php7.4-fpm php7.4-mysql php7.4-common php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-mbstring php7.4-soap php7.4-zip -y
- sudo systemctl start php7.4-fpm
Expand All @@ -49,16 +54,29 @@ runcmd:
- sed -i s/"export APACHE_RUN_GROUP=www-data"/"export APACHE_RUN_GROUP=ubuntu"/g /etc/apache2/envvars
- sed -i s/"index.html"/"index.php index.html"/g /etc/apache2/mods-enabled/dir.conf
- echo "Configuring PHP.ini"
- # Configure PHP.ini for 8.2
- touch /etc/php/8.2/apache2/conf.d/user.ini
- echo "display_errors=On" >> /etc/php/8.2/apache2/conf.d/user.ini
- echo "memory_limit=128M" >> /etc/php/8.2/apache2/conf.d/user.ini
- echo "upload_max_filesize=128M" >> /etc/php/8.2/apache2/conf.d/user.ini
- echo "post_max_size=1024M" >> /etc/php/8.2/apache2/conf.d/user.ini
- echo "max_execution_time=360" >> /etc/php/8.2/apache2/conf.d/user.ini
- echo "max_input_time=360" >> /etc/php/8.2/apache2/conf.d/user.ini
- echo "extension=soap" >> /etc/php/8.2/apache2/conf.d/user.ini
- chown ubuntu:ubuntu /etc/php/8.2/apache2/conf.d/user.ini
- # Configure PHP.ini for 8.1
- touch /etc/php/8.1/apache2/conf.d/user.ini
- echo "display_errors=On" >> /etc/php/8.1/apache2/conf.d/user.ini
- echo "memory_limit=128M" >> /etc/php/8.1/apache2/conf.d/user.ini
- echo "upload_max_filesize=128M" >> /etc/php/8.1/apache2/conf.d/user.ini
- echo "post_max_size=1024M" >> /etc/php/8.1/apache2/conf.d/user.ini
- echo "max_execution_time=360" >> /etc/php/8.1/apache2/conf.d/user.ini
- echo "max_input_time=360" >> /etc/php/8.1/apache2/conf.d/user.ini
- echo "extension=soap" >> /etc/php/8.1/apache2/conf.d/user.ini
- chown ubuntu:ubuntu /etc/php/8.1/apache2/conf.d/user.ini
- touch /etc/php/8.1/fpm/conf.d/user.ini
- echo "display_errors=On" >> /etc/php/8.1/fpm/conf.d/user.ini
- echo "memory_limit=128M" >> /etc/php/8.1/fpm/conf.d/user.ini
- echo "upload_max_filesize=128M" >> /etc/php/8.1/fpm/conf.d/user.ini
- echo "post_max_size=1024M" >> /etc/php/8.1/fpm/conf.d/user.ini
- echo "max_execution_time=360" >> /etc/php/8.1/fpm/conf.d/user.ini
- echo "max_input_time=360" >> /etc/php/8.1/fpm/conf.d/user.ini
- echo "extension=soap" >> /etc/php/8.1/fpm/conf.d/user.ini
- chown ubuntu:ubuntu /etc/php/8.1/fpm/conf.d/user.ini
- sed -i s/"user = www-data"/"user = ubuntu"/g /etc/php/8.1/fpm/pool.d/www.conf
- sed -i s/"group = www-data"/"group = ubuntu"/g /etc/php/8.1/fpm/pool.d/www.conf
- service php8.1-fpm restart
- # Configure PHP.ini for 8.0
- touch /etc/php/8.0/fpm/conf.d/user.ini
- echo "display_errors=On" >> /etc/php/8.0/fpm/conf.d/user.ini
Expand All @@ -71,7 +89,6 @@ runcmd:
- chown ubuntu:ubuntu /etc/php/8.0/fpm/conf.d/user.ini
- sed -i s/"user = www-data"/"user = ubuntu"/g /etc/php/8.0/fpm/pool.d/www.conf
- sed -i s/"group = www-data"/"group = ubuntu"/g /etc/php/8.0/fpm/pool.d/www.conf
- service apache2 restart
- service php8.0-fpm restart
- # Configure PHP.ini for 7.4
- touch /etc/php/7.4/fpm/conf.d/user.ini
Expand All @@ -85,8 +102,8 @@ runcmd:
- chown ubuntu:ubuntu /etc/php/7.4/fpm/conf.d/user.ini
- sed -i s/"user = www-data"/"user = ubuntu"/g /etc/php/7.4/fpm/pool.d/www.conf
- sed -i s/"group = www-data"/"group = ubuntu"/g /etc/php/7.4/fpm/pool.d/www.conf
- service apache2 restart
- service php7.4-fpm restart
- service apache2 restart
# Create directory to save phpmyadmin data
- mkdir /run/phpmyadmin
# PHPMyAdmin
Expand Down
34 changes: 34 additions & 0 deletions linux/scripts/multipass/sitesetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,40 @@ SSL_VIRTUAL_HOST="<IfModule mod_ssl.c>
</VirtualHost>
</IfModule>"

## PHP 8.1 virtual host
if [ "$PHP_VERSION" == '8.1' ]; then
SSL_VIRTUAL_HOST="<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName $SITE_NAME.test
ServerAdmin webmaster@$SITE_NAME.test
DocumentRoot $SITES_DIRECTORY/$SITE_NAME
<Directory \"$SITES_DIRECTORY/$SITE_NAME\">
#Require local
Order allow,deny
Allow from all
AllowOverride all
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/$SITE_NAME-error.log
CustomLog \${APACHE_LOG_DIR}/$SITE_NAME-access.log combined
SSLEngine on
SSLCertificateFile $SSL_CERTS_DIRECTORY/$SITE_NAME.test.pem
SSLCertificateKeyFile $SSL_CERTS_DIRECTORY/$SITE_NAME.test-key.pem
<FilesMatch \.php$>
# From the Apache version 2.4.10 and above, use the SetHandler to run PHP as a fastCGI process s>
SetHandler \"proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost\"
</FilesMatch>
<FilesMatch \"\.(cgi|shtml|phtml|php)\$\">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>"
fi

## PHP 8.0 virtual host
if [ "$PHP_VERSION" == '8.0' ]; then
SSL_VIRTUAL_HOST="<IfModule mod_ssl.c>
Expand Down
34 changes: 34 additions & 0 deletions macos/scripts/multipass/sitesetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,40 @@ SSL_VIRTUAL_HOST="<IfModule mod_ssl.c>
</VirtualHost>
</IfModule>"

## PHP 8.1 virtual host
if [ "$PHP_VERSION" == '8.1' ]; then
SSL_VIRTUAL_HOST="<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName $SITE_NAME.test
ServerAdmin webmaster@$SITE_NAME.test
DocumentRoot $SITES_DIRECTORY/$SITE_NAME
<Directory \"$SITES_DIRECTORY/$SITE_NAME\">
#Require local
Order allow,deny
Allow from all
AllowOverride all
# New directive needed in Apache 2.4.3:
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/$SITE_NAME-error.log
CustomLog \${APACHE_LOG_DIR}/$SITE_NAME-access.log combined
SSLEngine on
SSLCertificateFile $SSL_CERTS_DIRECTORY/$SITE_NAME.test.pem
SSLCertificateKeyFile $SSL_CERTS_DIRECTORY/$SITE_NAME.test-key.pem
<FilesMatch \.php$>
# From the Apache version 2.4.10 and above, use the SetHandler to run PHP as a fastCGI process s>
SetHandler \"proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost\"
</FilesMatch>
<FilesMatch \"\.(cgi|shtml|phtml|php)\$\">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>"
fi

## PHP 8.0 virtual host
if [ "$PHP_VERSION" == '8.0' ]; then
SSL_VIRTUAL_HOST="<IfModule mod_ssl.c>
Expand Down

0 comments on commit fdd9c31

Please sign in to comment.