Home » Php » apache – phpinfo says php.ini path is C:\Windows but there is no php.ini there

apache – phpinfo says php.ini path is C:\Windows but there is no php.ini there

Posted by: admin July 12, 2020 Leave a comment

Questions:

We are trying to switch from PHP5 to PHP7.

We now have Apache installed and PHP works.

However, the changes we made in the php.ini file have no effect.

Via phpinfo() we realized the reason is that the Configuration File (php.ini) Path is C:\Windows.

In our httpd.conf we have:

# PHP7 setup
LoadFile "C:/test/php/php7ts.dll"
LoadModule php7_module "C:/test/php/php7apache2_4.dll"
AddHandler php7-script .php
PHPINIDir "C:/test/php"

Which I understand is supposed to make Apache look for the php.ini in c:\test\php (forward slashes are used in the http.conf as is required)

Not understanding why Apache doesn’t look for php.ini where we tell it to, we put the php.ini in c:\Windows where it still is not read (the modules which we load in the php.ini are not loaded in phpinfo).

Each time we make changes to php.ini or httpd.conf, we restart Apache with the Apache monitor.

How can we tell Apache to read the php.ini file in a specific directory other than what we have tried above?

Addendum:

enter image description here

We switched everything back to PHP5 and now get the same error as in the above screenshot for where the PHP path is. It says it is now PHP 5.6.0 so it is obviously loading the new PHP version but something has changed so that the php.ini file is not read in either version. (???)

A reboot doesn’t help either.

How to&Answers:

You can try add trailing slash

PHPINIDir "C:/test/php/"

From manual

Note: Remember that when adding path values in the Apache configuration files on Windows, all backslashes such as
c:\directory\file.ext should be converted to forward slashes:
c:/directory/file.ext. A trailing slash may also be necessary for
directories.