简体   繁体   English

PHP不使用自定义php.ini文件

[英]PHP not using custom php.ini file

I have done this before so I'm not sure why it's not working, but I am trying to create a custom php.ini file and I have placed this within a specific directory. 我之前已经这样做过,所以我不确定为什么它不起作用,但是我正尝试创建一个自定义php.ini文件,并将其放置在特定目录中。

For example, the default php.ini is located at: 例如,默认的php.ini位于:

C:\xampp\php\php.ini 

My custom one is located at: 我的自定义网址位于:

D:\Codebase\Somedir\123\php.ini

I placed a PHP file inside the above directory and did output with phpinfo() and it still reports it as using C:\\xampp\\php\\php.ini . 我在上面的目录中放置了一个PHP文件,并使用phpinfo()进行了输出,但仍将其报告为使用C:\\xampp\\php\\php.ini

I have restarted Apache as well. 我也重新启动了Apache。

What am I doing wrong here!? 我在这里做错了什么!

You can see which php.ini file is loaded running php.exe --ini . 您可以看到运行php.exe --ini加载了哪个php.ini文件。 On my computer it output: 在我的计算机上,输出:

Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File:         C:\tools\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

If it is the wrong php.ini there, have a look to http://php.net/configuration.file 如果那里是错误的php.ini,请访问http://php.net/configuration.file

If you're using XAMPP you can change the configuration file it loads PHP with by opening the properties.ini file in the 如果您使用的是XAMPP,则可以通过打开以下文件中的properties.ini文件来更改加载PHP的配置文件

C:\xamp 

directory and editing the php_configuration_directory field to 目录,并将php_configuration_directory字段编辑为

D:\Codebase\Somedir\123\

Then restart apache for the changes to take effect. 然后重新启动apache以使更改生效。

If PHP is running as an apache module you could also edit httpd.conf on your apache setup and add this variable: 如果PHP作为apache模块运行,您还可以在apache设置中编辑httpd.conf并添加以下变量:

PHPIniDir "D:\Codebase\Somedir\123\" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM