2

I have a lot of differences between what is shown on console via php -i, and what is shown by apache via phpinfo().

For instance:

  • pdo_mysql exists for the first case, not for the second one.
  • include directive works only for the first case.

PHP.INI file is the same:

Console php -i:

Configuration File (php.ini) Path => /usr/local/etc/php/7.1

Loaded Configuration File => /usr/local/etc/php/7.1/php.ini

Scan this dir for additional .ini files => /usr/local/etc/php/7.1/conf.d

Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini

PDO drivers => mysql, odbc, sqlite

VS Web phpinfo():

Configuration File (php.ini) Path /usr/local/lib

Loaded Configuration File /usr/local/etc/php/7.1/php.ini

Scan this dir for additional .ini files (none)

Additional .ini files parsed (none)

PDO drivers sqlite


For additional info, here is my apache configuration:

LoadModule php7_module /usr/libexec/apache2/libphp7.so

PHPINIDir /usr/local/etc/php/7.1/

AddHandler application/x-httpd-php .php

And include directive in /usr/local/etc/php/7.1/php.ini

include=/usr/local/etc/php/7.1/conf.d/*.ini

I restarted apache after every php.ini modification.


Any idea, any clue?

4
  • 2
    because some servers use a cli-php.ini file for command line. In other words you may have separate config files one for Apache one for the Command line. Aug 8, 2017 at 1:02
  • @ArtisticPhoenix as you can see in the data given, it doesn't seem so. Loaded php.ini is the same.
    – theredled
    Aug 8, 2017 at 1:05
  • But in the second your missing this additional one, ext-xdebug.ini Aug 8, 2017 at 1:06
  • @ArtisticPhoenix you're right, that's one of the reasons why I created this thread...
    – theredled
    Aug 8, 2017 at 1:07

1 Answer 1

1

Solved, whereas php.ini was the same, there were 2 different PHP7 builds running on CLI and Apache. Tricky but solved!

6
  • 1
    Either by uninstalling all PHP instances and reinstalling just one, or by ensuring that your PHP Apache module (LoadModule php7_module [dir]/libphp7.so) points to to the same PHP as your command line PHP (which php)
    – theredled
    Mar 13, 2019 at 22:06
  • In my case I reinstalled everything with homebrew (OSX)
    – theredled
    Mar 13, 2019 at 22:14
  • How did you found there were 2 different builds?
    – EAmez
    Apr 29, 2022 at 8:23
  • @EAmez phpinfo() from webpage and command line gave different build numbers.
    – theredled
    May 27, 2022 at 17:42
  • 1
    @mario check the LoadModule directive, it's either in httpd.conf or something like /etc/apache/modules/php7_module.conf
    – theredled
    Aug 30, 2022 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.