What PHP Am I Running ?

Hi Guys,

I recently upgraded to php 7.2. I felt quite proud that i was able to do this on my own.

Typing the command php --version shows Im running 7.2

However in Wordpress, doing a system test shows Im running Php 5.xxx

Why does Wordpress not seem to be picking up that we updated to 7.2 ?

3 Replies

You need to update your config files and restart Apache, Nginx or PHP-FPM, otherwise the daemon won't pick the new version.

You can also test which PHP version by creating a file with the following:

File: phpinfo.php

<?php

phpinfo();

Hey thanks for the reply.

Will a linode reboot restart Apache, Nginx and PHP-fpm or do I need to do that via connecting to root ?

It sounds like you have your CLI configured to use PHP7.2 but your web server is still using the older version. As @AlfredoRamos mentioned, this requires some configuration changes and restarting services.

Apache:

sudo a2dismod php5*
sudo a2enmod php7.2
sudo a2enmod proxy_fcgi setenvif
sudo systemctl restart apache2||httpd
sudo systemctl restart php*

Nginx:

Note the listening socket in the www.conf file. If you’re using CentOS, depending on which repo you used to install PHP7.2, the absolute path may very. Use the find command if you need help locating it.

sudo find / -name www.conf
cat /path/to/www.conf | grep "listen ="

Example outputs:
listen = 127.0.0.1:9000 for CentOS and /run/php/php7.2-fpm.sock for Debian.

Update the server block in your site’s configuration.

location ~* \.php$ {
  fastcgi_pass unix:/run/php/php7.2-fpm.sock. #127.0.0.1:9000 for CentOS
  include         fastcgi_params;
  fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
  fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

Restart PHP and reload Nginx.

sudo systemctl restart php7*
sudo nginx -s reload

You might also find these resources helpful if using Plesk, cPanel, or OpenLightSpeed.

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