PHP version discrepancy

I have a WordPress install on a Ubuntu (18.04.1) droplet. WordPress site health thinks I have PHP 7.0.33. Doing php -v in terminal indicates I have PHP 8.1.13 (built today it was showing 8.1.5 before I updated).

I cannot figure out how to kick WordPress in the nuts to make it realize it has access to the right version.

I’m not sure if I have two versions of PHP running (nor how to check, TBH).

I’ve been looking for tutorials and information on DO and elsewhere the whole morning and am coming up empty.

Any help would be greatly appreciated.

Show comments

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.

Site Moderator
Site Moderator badge
December 11, 2022

Hi @vavroom,

I did notice something else on your Post. You’ve marked the Ubuntu 18.04. If you are still using it, I’ll strongly recommend upgrading to the newest version as soon as possible.

Site Moderator
Site Moderator badge
November 29, 2022

Hi @vavroom,

Yes, you have two or possibly more PHP versions. Anyway, you need to tell your WebService (Apache/Nginx) what PHP version to use.

First disable the current PHP version

  1. $ sudo a2dismod php7

Now enable the one you want

$ sudo a2enmod php8.1

Set PHP 8 as default version using command:

  1. sudo update-alternatives --set php /usr/bin/php8.1

Alternatively, you can run the following command to set which system wide version of PHP you want to use by default.

$ sudo update-alternatives --config php

Finally, restart your Apache web server:

$ sudo systemctl restart apache2

Apart from the update-alternatives commands the others were for Apache. If you are using Nginx, you need to edint your nginx config file for your website and change the php version it uses there:

$ sudo vim /etc/nginx/sites-available/yourWebsite.conf

In there find the php block:

location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7-fpm.sock;

See the fastcgi_pass? Change the PHP from /run/php/php7-fpm.sock; to /run/php/php8.1-fpm.sock;

Try DigitalOcean for free

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

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

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

This promotional offer applies to new account only.

© 2023 DigitalOcean, LLC.