How to upgrade PHP from 7.0 to 7.2 on Debian 9

I have a Virtualmin install which currently only has PHP 7.0, with several virtual servers running WordPress, where it is highly recommended to switch to PHP 7.2 as 7.0 reached end of life over a year ago, 7.2 is faster, etc.etc.... I've done some searching around regarding Virtualmin, Debian, and PHP and not found anything that was specific to this situation. Can you possibly guide me (with as much detail as possible) on how I can accomplish the upgrade to PHP7.2 on Debian 9?

Status: 
Closed (fixed)

Comments

Ilia's picture
Submitted by Ilia on Tue, 02/25/2020 - 06:01

Status:
Active
»
Closed (fixed)

Hi,

It's very easy, run the following commands as root:

apt install ca-certificates apt-transport-https 
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list
apt update
apt install php7.2 php7.2-fpm
apt install php7.3 php7.3-fpm
apt install php7.4 php7.4-fpm

Note: You don't have to install all of the mentioned versions above, just choose the one you need. Later you will be able to change it on PHP versions page.

Thank you for your help. I followed the steps you provided below up through the install of php7.2 . I then went to ‘Server Configuration > PHP Versions’ for one of my development virtual servers and selected 7.2.28 and clicked the ‘Save Versions’ button. Next I tried accessing the WordPress site on that virtual server and got the following error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.

I checked the Apache Error Log for that virtual server and found the following: [Tue Feb 25 12:22:25.243220 2020] [fcgid:warn] [pid 20994] (104)Connection reset by peer: [client 79.224.136.130:54152] mod_fcgid: error reading data from FastCGI server [Tue Feb 25 12:22:25.243275 2020] [core:error] [pid 20994] [client 79.224.136.130:54152] End of script output before headers: index.php [Tue Feb 25 12:22:25.370669 2020] [fcgid:warn] [pid 14488] (104)Connection reset by peer: [client 79.224.136.130:54153] mod_fcgid: error reading data from FastCGI server, referer: https://dev.posi-tone.com/ [Tue Feb 25 12:22:25.370718 2020] [core:error] [pid 14488] [client 79.224.136.130:54153] End of script output before headers: index.php, referer: https://dev.posi-tone.com/

Fwiw, I notice that under ‘Services’, only 'PHP 7.0 Configuration’ is shown (as before). Shouldn’t there be an entry for ‘PHP 7.2 Configuration’?

  • -
Ilia's picture
Submitted by Ilia on Tue, 02/25/2020 - 07:15

Fwiw, I notice that under ‘Services’, only 'PHP 7.0 Configuration’ is shown (as before). Shouldn’t there be an entry for ‘PHP 7.2 Configuration’?

Try running Re-Checking Configuration overy again.

Next I tried accessing the WordPress site on that virtual server and got the following error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

Go to Webiste Options and try changing PHP execution modes. For example FPM to FCGI and then FCGI back to FPM.