Question

How to force Wordpress to recognize new PHP 7.4 install in ubuntu

I have installed php7.4 and installed all the packages and updates. Rebooted my droplet, restarted apache, cleared all caches, etc. My server is running php version 7.4. But my wordpress installation is still using PHP 5.x and warning me about needing to update. I’ve followed every how-to and tutorial. I tried to disable 5.x and the site broke. I’ve looked through .htaccess and wp-config.php, etc etc, there’s nothing conflicting or even mentioning php versions.

Anyone have any advice? is there a way to force wordpress to use php7.4? Where in the wordpress back-end does it even mention which php to use if it won’t default to the newest version?

Thanks!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
September 6, 2020
Accepted Answer

Hi @todderik,

You need to tell Apache/Nginx to use the newly installed PHP verson.

Apache

You need to tell Apache to use the installed version of PHP 7.4 by disabling the old PHP module and enabling the new PHP module using the following command.

sudo a2dismod php5.X
sudo a2enmod php7.4

Remember to change 5.X with your actual PHP version.

Restart Apache for the changes to take effect.

sudo service apache2 restart

Nginx

For Nginx you need to install FPM, execute the following command to install PHP 7.4 FPM

sudo apt install php7.4-fpm

After the installation has completed, confirm that PHP 7.4 FPM has installed correctly with this command

php-fpm7.4 -v

For Nginx you need to update the PHP-FPM socket in your Nginx configuration located inside the sites-available directory. This will be located inside the location block location ~ \.php$

sudo nano /etc/nginx/sites-available/your.conf

The line you need to modify will look like this…

fastcgi_pass unix:/run/php/php5.X-fpm.sock; 

You need to replace the old PHP version with the new version.

fastcgi_pass unix:/run/php/php7.4-fpm.sock; 

Regards, KFSys

Hi all, I put in contact with the hosting and we solved it in this way:

We found out that phpSelector in cPanel only worked when changed from 5.6 to 7.2; but not to 7.3 or 7.4, where the site crashed.

The technician finally found in phpSelector that mysqli was disable. Higher php version -> more modules to apply.

It worked perfectly and now I have 7.4.12

I hope it helps. Best

Hi, I’m in the same situation. However its very well explained I have no idea how to solve this in Apache…

Question: Shouldn’t that be a problem for the hosting company to fix?

Thx in advance. Best,

Carlos Abellanosa

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.