Change php.ini location

对着背影说爱祢 提交于 2020-01-10 13:16:34

问题


Is it possible to change the location of php.ini to be used by Apache? When I did php -i | grep 'Configuration File', the result is:

Path => /usr/local/etc

Loaded Configuration File => /usr/local/etc/php.ini

But the result of phpinfo() is

Configuration File (php.ini) Path : /etc

I can copy over php.ini from /usr/local/etc/ to /etc/, but is it possible to change the php.ini folder?

I installed PHP using homebrew and I am using OS X Snow Leopard.


回答1:


PHP uses different .ini files when running via command line vs running as a web server module. When you grep the results of php -i your getting the command line ini. It's good practice to have separate ini's for the two environments.

If you must change the directory PHP looks for the php.ini file, you can use the PHPIniDir in your web server conf file.

If you wish to just add additional directories to be scanned, you can set the PHP_INI_SCAN_DIR environment variable.




回答2:


To Change php.ini file path we have to declare PHPINIDir in the apache configuration file 'httpd.conf' syntax for that is :

PHPINIDir "path_to_ini_file";


来源:https://stackoverflow.com/questions/10386188/change-php-ini-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!