0

If I run php --ini,then I get the following warnings.

Cannot load Xdebug - it was already loaded
PHP Warning:  Module 'memcached' already loaded in Unknown on line 0
....
Configuration File (php.ini) Path: /opt/Qapache/etc
Loaded Configuration File:         /opt/Qapache/etc/php.ini
Scan for additional .ini files in: /opt/Qapache/etc
Additional .ini files parsed:      /opt/Qapache/etc/php.ini

Yeah, i run a Qnap NAS. If I comment out the modules in the php.ini like here, they will not be loaded anymore.

So my thought is that the php.ini file is loaded twice by the path for "Scan for additional .ini files in:".

I know that I can override the php execution with the following command php -c /PATH/TO/php.ini -n so it looks like this.

Configuration File (php.ini) Path: /opt/Qapache/etc
Loaded Configuration File:         /PATH/TO/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

And that works, none module was already loaded.

But this is not persistent and I don't want to use the options for it every time. So, how do I change the path for Scan for additional .ini files in: in general?

Thanks in advance.

  • is this your answer ? https://stackoverflow.com/questions/10844641/how-to-change-the-path-to-php-ini-in-php-cli-version –  Feb 04 '20 at 12:03
  • @Dilek If I understand this correctly, the question refers to the main php.ini. Also the variable $PHPRC. Accordingly, it does not refer to the additional paths. – itchybellybutton Feb 06 '20 at 11:06

1 Answers1

1

That directory is defined when PHP is compiled from source code using the custom flag --with-config-file-scan-dir: https://www.php.net/manual/en/configure.about.php#configure.options.php

You can change it at run time by setting an ENV var called PHP_INI_SCAN_DIR as defined in the documentation: https://www.php.net/manual/en/configuration.file.php#configuration.file.scan

Octavian
  • 4,519
  • 8
  • 28
  • 39
  • Setting the ENV works. Thank. But shouldn't the flag be `--with-config-file-scan-dir`, according to your second link? `--with-config-file-path` should be for the main `php.ini`. – itchybellybutton Feb 06 '20 at 11:06
  • @itchybellybutton You are indeed right, I have modified my answer. – Octavian Feb 06 '20 at 15:06