My website says I need to upgrade PHP, but php -v shows the current version. Why?

Linode Staff

My Wordpress site is showing a message that I need to upgrade to a newer version of PHP. When I use php -v in the command line, I already am running the newest version. When I check the PHP version via my website, I'm still on PHP 5. Why is this happening and how can I upgrade?

1 Reply

Linode Staff

Currently you have both versions of PHP installed, but the older version is enabled. You'll need to change the version of PHP that is enabled for your web server. If you're using Apache, you can use the following set of commands:

  1. sudo a2dismod php5.6.40 (if you get an error message signifying that the package cannot be found, the syntax may need to be php5 instead)
  2. sudo a2enmod php7.3.9 (similarly, this may need to be php7.0 instead)
  3. sudo service apache2 restart

If you're using Nginx, you'll need to change settings in the configuration file itself:

  1. Open /etc/nginx/sites-available/default in a text editor in the command line
  2. Change the FastCGI block to use the new version of PHP as follows:
location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}

The wording of php7.3 may need to be adjusted depending on how the version is read by your system.

  1. Check your configuration by using nginx -t
  2. Restart Nginx using sudo service nginx restart

More information about the above steps can be found via this website.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct