Report this

What is the reason for this report?

php -v is 7.0.11 and phpinfo() is 5.5.9

Posted on October 3, 2016

I have updated php to 7.0. php -v return 7.0.11. But phpinfo() return 5.5.9.

Can anyone help me?



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!

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.

Did you switched PHP modules on Apache? You should first disable PHP5.6 module then enable PHP7 module and restart Apache. To disable PHP5.6 on Apache execute :

  1. sudo a2dismod php5.6

Now you should enable PHP7 ones:

  1. sudo a2enmod php7.0

To reflect changes Apache restart is required:

  1. sudo systemctl restart apache2

Try again phpinfo, and report is it or we need to try something other. :) Edit: try with php5.5 if php5.6 returns not exist module, I noticed it late :P

This is a common issue and typically arises from the fact that the PHP version being used by your command line (CLI) can be different from the one being used by your web server. In your case, PHP 7.0 is installed and available via the command line, but your web server (probably Apache or Nginx with PHP-FPM) is still using PHP 5.5.

To solve this, you need to make sure that your web server is configured to use the correct version of PHP. How to do this depends on your exact server setup. Below are general steps for both Apache and Nginx.

For Apache:

You might have multiple versions of libphp installed and Apache is configured to use the older one.

  1. Disable the old PHP module: sudo a2dismod php5.5 (or whatever version is currently enabled)

  2. Enable the new PHP module: sudo a2enmod php7.0

  3. Restart Apache to apply changes: sudo systemctl restart apache2

For Nginx with PHP-FPM:

  1. Find your Nginx site configuration (usually located at /etc/nginx/sites-available/).

  2. In the server block, locate the fastcgi_pass directive inside the PHP location block. It should look something like this:

location ~ \.php$ {
    # ...
    fastcgi_pass unix:/var/run/php/php5.5-fpm.sock;
    # ...
}
  1. Change the fastcgi_pass directive to point to the PHP 7.0 FPM socket. It might look like this:
location ~ \.php$ {
    # ...
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    # ...
}
  1. Restart Nginx to apply changes: sudo systemctl restart nginx

  2. Also ensure that PHP 7.0 FPM service is running. If it’s not, start it: sudo systemctl start php7.0-fpm

Please adjust the commands and paths as necessary according to your actual server setup. The version numbers and paths might vary depending on how PHP was installed and configured on your server. If these instructions do not help or if you’re using a different web server, please provide more details about your setup.

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.