My website says I need to upgrade PHP, but php -v shows the current version. Why?
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
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:
sudo a2dismod php5.6.40
(if you get an error message signifying that the package cannot be found, the syntax may need to bephp5
instead)sudo a2enmod php7.3.9
(similarly, this may need to bephp7.0
instead)sudo service apache2 restart
If you're using Nginx, you'll need to change settings in the configuration file itself:
- Open /etc/nginx/sites-available/default in a text editor in the command line
- 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.
- Check your configuration by using
nginx -t
- Restart Nginx using
sudo service nginx restart
More information about the above steps can be found via this website.