Gold/PHP 8 Scratchpad/Add PHP8: Difference between revisions
From Mahara Wiki
< User:Gold | PHP 8 Scratchpad
(Created page with "== Check available versions == <syntaxhighlight lang=bash> gold@shipnet:~/$ apt-cache search php | sort | grep fpm php7.4-fpm - server-side, HTML-embedded scripting language (...") |
No edit summary |
||
Line 23: | Line 23: | ||
php8.1-ldap php8.1-mbstring php8.1-pgsql php8.1-xml \ | php8.1-ldap php8.1-mbstring php8.1-pgsql php8.1-xml \ | ||
php8.1-xmlrpc php8.1-zip | php8.1-xmlrpc php8.1-zip | ||
</syntaxhighlight> | |||
=== Set up Apache === | |||
I'm configuring 2 sites. One for PHP 7.4 and one for PHP 8.1. At this point I'm not supporting PHP 7.2 and 8.0 is not the default in Ubuntu 22.04 which is our target platform. | |||
I have updated my local <syntaxhighlight lang=bash inline>/etc/hosts</syntaxhighlight> file and added entries for https://php74.mahara.local/ and https://php81.mahara.local/. While I'm ignoring 7.2 and 8.0 I'm including the minor version for future-proofing. Just in case. | |||
Next the following is added as mahara-php8.conf and a <syntaxhighlight lang=bash inline>sudo a2ensite mahara-php8 && sudo systemctl reload apache2</syntaxhighlight> to enable it. | |||
==== /etc/apache2/sites-available/mahara-php8.conf ==== | |||
<syntaxhighlight lang=xml> | |||
<VirtualHost *:80> | |||
ServerName php81.mahara.local | |||
DocumentRoot /home/gold/Mahara/php8/htdocs | |||
<Directory /home/gold/Mahara/codereview> | |||
Options Indexes FollowSymLinks MultiViews | |||
Require all granted | |||
</Directory> | |||
ErrorLog /var/log/apache2/error.log | |||
LogLevel debug | |||
CustomLog /var/log/apache2/access.log combined | |||
DirectoryIndex index.php index.html | |||
</VirtualHost> | |||
<IfModule mod_ssl.c> | |||
<VirtualHost _default_:443> | |||
ServerName php81.mahara.local | |||
DocumentRoot /home/gold/Mahara/php8/htdocs | |||
SSLEngine on | |||
SSLCertificateFile /etc/apache2/ssl/apache.crt | |||
SSLCertificateKeyFile /etc/apache2/ssl/apache.key | |||
<FilesMatch \.php$> | |||
SSLOptions +StdEnvVars | |||
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost" | |||
</FilesMatch> | |||
<Directory /home/gold/Mahara/php8> | |||
SSLOptions +StdEnvVars | |||
DirectoryIndex index.php | |||
Options Indexes FollowSymLinks MultiViews | |||
Require all granted | |||
</Directory> | |||
ErrorLog /var/log/apache2/error.log | |||
LogLevel info | |||
CustomLog /var/log/apache2/access.log combined | |||
</VirtualHost> | |||
</IfModule> | |||
<VirtualHost *:80> | |||
ServerName php74.mahara.local | |||
DocumentRoot /home/gold/Mahara/php8/htdocs | |||
<Directory /home/gold/Mahara/codereview> | |||
Options Indexes FollowSymLinks MultiViews | |||
Require all granted | |||
</Directory> | |||
ErrorLog /var/log/apache2/error.log | |||
LogLevel debug | |||
CustomLog /var/log/apache2/access.log combined | |||
DirectoryIndex index.php index.html | |||
</VirtualHost> | |||
<IfModule mod_ssl.c> | |||
<VirtualHost _default_:443> | |||
ServerName php74.mahara.local | |||
DocumentRoot /home/gold/Mahara/php8/htdocs | |||
SSLEngine on | |||
SSLCertificateFile /etc/apache2/ssl/apache.crt | |||
SSLCertificateKeyFile /etc/apache2/ssl/apache.key | |||
<FilesMatch \.php$> | |||
SSLOptions +StdEnvVars | |||
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost" | |||
</FilesMatch> | |||
<Directory /home/gold/Mahara/php8> | |||
SSLOptions +StdEnvVars | |||
DirectoryIndex index.php | |||
Options Indexes FollowSymLinks MultiViews | |||
Require all granted | |||
</Directory> | |||
ErrorLog /var/log/apache2/error.log | |||
LogLevel info | |||
CustomLog /var/log/apache2/access.log combined | |||
</VirtualHost> | |||
</IfModule> | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 15:13, 16 Mayıs 2022
Check available versions
gold@shipnet:~/$ apt-cache search php | sort | grep fpm
php7.4-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary) (default)
If there are no php 8 options we need to add the repo and check again.
gold@shipnet:~/$ sudo add-apt-repository ppa:ondrej/php
You will likely be challenged to install ppa:ondrej/apache2. We are not using mod-php so there is no need to do that.
To check php8 is available rerun the apt-cache
call above. You should see many more options.
Install PHP 7.4 and 8.1
Testing on PHP 7.4 and PHP 8.1 so install the related supporting packages that Mahara needs. There is no php8.1-json
package. This is part of php8.1-common
now.
gold@shipnet:~/$ sudo apt install \
php7.4-cli php7.4-common php7.4-curl php7.4-gd \
php7.4-json php7.4-ldap php7.4-mbstring php7.4-pgsql \
php7.4-xml php7.4-xmlrpc php7.4-zip \
php8.1-cli php8.1-common php8.1-curl php8.1-gd \
php8.1-ldap php8.1-mbstring php8.1-pgsql php8.1-xml \
php8.1-xmlrpc php8.1-zip
Set up Apache
I'm configuring 2 sites. One for PHP 7.4 and one for PHP 8.1. At this point I'm not supporting PHP 7.2 and 8.0 is not the default in Ubuntu 22.04 which is our target platform.
I have updated my local /etc/hosts
file and added entries for https://php74.mahara.local/ and https://php81.mahara.local/. While I'm ignoring 7.2 and 8.0 I'm including the minor version for future-proofing. Just in case.
Next the following is added as mahara-php8.conf and a sudo a2ensite mahara-php8 && sudo systemctl reload apache2
to enable it.
/etc/apache2/sites-available/mahara-php8.conf
<VirtualHost *:80>
ServerName php81.mahara.local
DocumentRoot /home/gold/Mahara/php8/htdocs
<Directory /home/gold/Mahara/codereview>
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel debug
CustomLog /var/log/apache2/access.log combined
DirectoryIndex index.php index.html
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName php81.mahara.local
DocumentRoot /home/gold/Mahara/php8/htdocs
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch \.php$>
SSLOptions +StdEnvVars
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
</FilesMatch>
<Directory /home/gold/Mahara/php8>
SSLOptions +StdEnvVars
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel info
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
</IfModule>
<VirtualHost *:80>
ServerName php74.mahara.local
DocumentRoot /home/gold/Mahara/php8/htdocs
<Directory /home/gold/Mahara/codereview>
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel debug
CustomLog /var/log/apache2/access.log combined
DirectoryIndex index.php index.html
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName php74.mahara.local
DocumentRoot /home/gold/Mahara/php8/htdocs
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch \.php$>
SSLOptions +StdEnvVars
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
<Directory /home/gold/Mahara/php8>
SSLOptions +StdEnvVars
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel info
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
</IfModule>