[英]PHP ignores its php.ini in Windows
I use PHP
on my Windows host system for composer
. 我在Windows主机系统上使用
PHP
composer
。 After a failed attempt to add parse/php-sdk
to a project (since the SDK needs the PHP cURL module to be enabled), I updated the PHP settings. 尝试将
parse/php-sdk
添加到项目失败后(由于SDK需要启用PHP cURL模块),我更新了PHP设置。 But it didn't solve the problem. 但这并不能解决问题。 Then I checked, whether the
php.ini
settings are correct: 然后我检查了
php.ini
设置是否正确:
C:\Users\me>php --info | grep "extension_dir"
extension_dir => ext => ext
C:\Users\me>php --info | grep "php.ini"
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\Program Files\php-5.6.8-Win32-VC11-x64\php.ini
Yes, they are. 对,他们是。 There is no
C:\\Windows\\php.ini
, but it doesn't matter -- the C:\\Program Files\\php-5.6.8-Win32-VC11-x64\\php.ini
is the file I updated and it's loaded. 没有
C:\\Windows\\php.ini
,但没关系C:\\Program Files\\php-5.6.8-Win32-VC11-x64\\php.ini
是我更新的文件并已加载。
Then I printed the modules list ( php --modules
) and noticed, that it has nothing in common with the extensions setting in the loaded php.ini
. 然后,我打印了模块列表(
php --modules
)并注意到,它与加载的php.ini
的扩展名设置没有共同之处。 I also tried to change other settings (like memory_limit
), but PHP seems to ignore my php.ini
and load the configurations from somewhere else. 我还尝试更改其他设置(例如
memory_limit
),但是PHP似乎忽略了我的php.ini
并从其他位置加载了配置。
How to detect this magical "somewhere" (means: where PHP actually loads its settings from) and how to make it load the wished settings from the defined file? 如何检测到这个神奇的“某处”(意思是:PHP实际上从何处加载其设置)以及如何使其从定义的文件中加载所需的设置?
The problem is caused by the fact, that php.ini is being edited by editor that wasn't run with elevated privileges. 该问题是由于以下事实造成的:php.ini由未以提升特权运行的编辑器进行编辑。 If the PHP folder sits inside "Program Files", you have to access the files within it with admin privileges.
如果PHP文件夹位于“程序文件”中,则您必须使用管理员权限访问其中的文件。 I discovered the unbelievable fact, that the changes aren't saved into the php.ini despite the editor shows them correctly, even if closed/opened!
我发现了一个令人难以置信的事实,即使编辑器正确显示了更改,即使已关闭/打开,这些更改也没有保存到php.ini中! This can be simply verified by checking php.ini content - run
more "C:\\Program Files\\... ...\\php.ini"
from the command line. 这可以通过检查php.ini内容来简单地验证-从命令行运行
more "C:\\Program Files\\... ...\\php.ini"
。
The solution is obvious - you have to run the editor with elevated privileges, or grant user permissions to the folder with php.ini and then edit it. 解决方案很明显-您必须以提升的权限运行编辑器,或者使用php.ini授予用户对该文件夹的权限,然后对其进行编辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.