If you are running PHP FPM 7.x version(s) and thinking it’s time to upgrade, this article will guide you how to upgrade PHP FPM.
If you have a fresh installation and want to setup http2 with PHP FPM and Apache, click the button below to install and configure http2.
Check the current status of PHP FPM. Change version accordingly, e.g: php7.3-fpm
systemctl status php7.2-fpm
Installation
Note: Please note that here we will only cover upgrading as many initial configurations are skipped.
Add the following repository and update the repositories meta.
sudo add-apt-repository ppa:ondrej/php
sudo apt update
We are going to install php8.0
, if you want to install php7.4
, just change the version. For example php8.0-gmp
to php7.4-gmp
.
apt install php8.0 php8.0-gmp php8.0-bcmath php8.0-gd php8.0-json php8.0-mysql php8.0-curl php8.0-mbstring php8.0-intl php8.0-imagick php8.0-xml php8.0-zip php8.0-fpm php8.0-fileinfo php8.0-apcu php8.0-opcache
If you have previously installed any version, disable it’s configuration. To disable it for PHP 7.2:
a2disconf php7.2-fpm
systemctl stop php7.2-fpm
Enable for PHP 8.0:
a2enconf php8.0-fpm
systemctl enable php8.0-fpm
systemctl start php8.0-fpm
Check the configuration and restart Apache.
apachectl configtest
systemctl restart apache2
PHP configuration file will be in /etc/php/8.0/fpm/php.ini
.
Sock file created in /run/.
ls /run/php
For Nextcloud
This part is for Nextcloud installed on older versions of Ubuntu e.g: 18.04.
If your app has config files for http and https in /etc/apache2/sites-available
, look for this part and change the PHP version accordingly:
SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost/"
If you have an app configuration created previously in /etc/php/7.2/fpm/pool.d/APP.conf,
you need to copy that to /etc/php/8.0/fpm/pool.d/APP.conf
.
I assume you have PHP FPM 7.2 and APP.conf filename is nextcloud.conf.
cp /etc/php/7.2/fpm/pool.d/nextcloud.conf /etc/php/8.0/fpm/pool.d/
And change this in nextcloud.conf:
SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost/"
to
SetHandler "proxy:unix:/var/run/php/php8.0-fpm.sock|fcgi://localhost/"
Troubleshooting
If you get this error when starting php8.0-fpm.
[pool www] unable to set listen address as it’s already used in another pool www.
www
is the pool config file name. Just move this file and restart PHP FPM.
mv /etc/php/8.0/fpm/pool.d/www.conf /etc/php/8.0/fpm/pool.d/www.conf.bak
systemctl restart php8.0-fpm