php -v is 7.0.11 and phpinfo() is 5.5.9

October 3, 2016 245 views
Apache LAMP Stack PHP Ubuntu

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

Can anyone help me?

1 Answer

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 :

  • sudo a2dismod php5.6

Now you should enable PHP7 ones:

  • sudo a2enmod php7.0

To reflect changes Apache restart is required:

  • 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

  • I have done this, but Apache returned error:

    The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
    • I guess log file will give you more information.

      Can you find something in /var/log/apache2/error.log

      Open it with any text editor e.g. nano /var/log/apache2/error.log and look there for any errors

      • In error.log file is error:

        ah00169 caught sigterm shutting down
        • Not something that describes a lot. Do you have any other log?

          Hmmm, maybe it is PHP module mismatch.
          What if you execute:

          • sudo apt-get install libapache2-mod-php7.0

          If that fails you can try:

          • sudo apt-get install libapache2-mod-php

          Try to start Apache again and look again at logs if there is error

          • Libapache2 is already installed:

            libapache2 mod php7 is already the newest version

            Three last errors are:

            [mpm_prefork:notice] [pid 8175] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4 configured -- resuming normal operations
            [core:notice] [pid 8175] AH00094: Command line: '/usr/sbin/apache2'
            [mpm_prefork:notice] [pid 8175] AH00169: caught SIGTERM, shutting down
        • I can't reply to latest comment.
          Looks like it is absolutely trying to use php5.

          Verify enabled mods:

          • ls -la /etc/apache2/mods-enabled/php*

          You can also check whole directory :

          • ls -la /etc/apache2/mods-enabled/

          You should not have any trace of php5 there. If you find report what you have

        • Again not being able to reply.
          You have php5 module enabled. You can try to disable it if you don't use.

          • sudo a2dismod php5filter

          Check again for PHP5 modules. If you find php5filter again,
          remove php5filter.conf and php5filter.load
          You can also remove that package :

          • sudo apt-get remove libapache2-mod-php5filter

          Try again to start Apache and post logs if not working

Have another answer? Share your knowledge.