phpinfo说php.ini路径是C:\ Windows,但是那里没有php.ini [英] phpinfo says php.ini path is C:\Windows but there is no php.ini there
问题描述
我们正在尝试从PHP5切换到PHP7.
我们现在已经安装了Apache,并且可以使用PHP.
但是,我们在 php.ini
文件中所做的更改无效.
通过 phpinfo()
,我们意识到原因是配置文件(php.ini)路径
是 C:\ Windows
./p>
在我们的 httpd.conf
中,我们有:
#PHP7设置加载文件"C:/test/php/php7ts.dll"LoadModule php7_module"C:/test/php/php7apache2_4.dll"AddHandler php7脚本.phpPHPINIDir"C:/test/php"
据我所知,这应该使Apache在 c:\ test \ php
中查找 php.ini
(正斜杠按原样在http.conf中使用必填)
不理解为什么Apache不会在我们告诉它的地方寻找 php.ini
,因此将 php.ini
放在 c:\ Windows
仍然无法读取的地方(我们在 php.ini
中加载的模块未在phpinfo中加载).
每次我们更改 php.ini
或 httpd.conf
时,都会使用Apache监视器重新启动Apache.
除了上面我们尝试过的方法之外,我们如何告诉Apache读取特定目录中的 php.ini
文件?
附录:
我们将所有内容都切换回了PHP5,现在与上述屏幕快照中的PHP路径相同,出现了相同的错误.它说现在是PHP 5.6.0,因此它显然正在加载新的PHP版本,但是有所更改,因此在任何一个版本中都不会读取php.ini文件.(???)
重启也无济于事.
您可以尝试添加斜杠
PHPINIDir"C:/test/php/"
来自手册
注意:请记住,在Windows上的Apache配置文件中添加路径值时,所有反斜杠(例如)c:\ directory \ file.ext应该转换为正斜杠:c:/directory/file.ext.对于以下情况,也可能需要使用斜杠目录.
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:
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.
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.
这篇关于phpinfo说php.ini路径是C:\ Windows,但是那里没有php.ini的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!