Vannkorn

Full Stack Web Developer

Close

Install PHP8.3-FPM on Hestia CP that Runs on Ubuntu 24.04 LTS

I've just upgraded one of my Ubuntu servers from 20.04 LTS to 24.04 LTS. From the documentation it says the Ubuntu 24.04 LTS comes with PHP8.3, but in my case the PHP8.0.3 as still in used even if I had enabled the PHP8.3.

Ads: Register now via this link to receive $300 credit from Vultr

I’ve just upgraded one of my Ubuntu servers from 20.04 LTS to 24.04 LTS. From the documentation it says the Ubuntu 24.04 LTS comes with PHP8.3, but in my case the PHP8.0.3 as still in used even if I had enabled the PHP8.3.

To fix this, I switched to PHP8.3-FPM and discard the natural PHP8.3.

First, we need to install PHP8.3-FPM and enable it:

sudo apt update && apt upgrade -y
sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.3-fpm -y
sudo systemctl enable --now php8.3-fpm

To enable PHP8.3-FPM, we need to run:

sudo update-alternatives --config php

Then the dialogue will pop up and ask you to select the version of PHP you wish to switch to:

In this case, I need to hit number ‘2’ to switch from PHP7.4-fpm to PHP8.3-fpm

Install extensions that your sites may need to run:

sudo apt install php8.3-cli php8.3-fpm php8.3-mysql php8.3-curl php8.3-gd php8.3-mbstring php8.3-xml php8.3-zip php8.3-intl php8.3-bcmath -y
sudo systemctl restart php8.3-fpm
sudo systemctl restart apache2

After this, if you see your site throws the 500 internal error message, that is because HestiaCP had per-domain PHP-FPM pools which means one domain will have a configuration file for it. You might see only one file ‘www.conf’ in the ‘/etc/php/8.3/fpm/pool.d’.

To fix this, copy the previous per-domain PHP-FPM pools from your old configuration. In my case they are located in the ‘/etc/php/8.0/fpm/pool.d/’. So the command would be:

sudo cp /etc/php/8.0/fpm/pool.d/*.conf /etc/php/8.3/fpm/pool.d/

Then navigate to ‘/etc/php/8.3/fpm/pool.d/’ and make sure the ‘listen’ socket points to PHP 8.3.

listen = /run/php/php8.3-fpm-cambodiatrending.com.sock

Also make sure all files have its appropriate permission:

sudo chown -R user1:group1 *

Since were’re using PHP-FPM instead of the mod_fcgid, let’s disable this mod and reload the Apache

sudo a2dismod fcgid
sudo systemctl restart apache2

Restart PHP8.3-FPM

sudo systemctl restart php8.3-fpm

Finally, we need to update the Hestia configuration it uses Nginx/Apache templates pointing to the old pool socket (e.g., /run/php/php8.0-fpm-site.com.sock).

To do this, we need to run the following command:

/run/php/php8.3-fpm-site.com.sock

Or, by using GUI, login to Hestia Panel and hit “Rebuild Web Configs” for all domains by going to HestiaCP → Web → Rebuild Config for each domain. This will automatically update the socket to PHP 8.3 pool.

If you encounter another 500 internal server error and your PHP8.3-FPM can’t be reloaded, this could be causing from the cache. Therefore we need to purge them by running:

sudo apt purge php7.4* php8.0* -y
sudo systemctl restart apache2 php8.3-fpm

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *