简体   繁体   English

更改php.ini位置

[英]Change php.ini location

Is it possible to change the location of php.ini to be used by Apache? 是否可以更改Apache使用的php.ini的位置? When I did php -i | grep 'Configuration File' 当我做php -i | grep 'Configuration File' php -i | grep 'Configuration File' , the result is: php -i | grep 'Configuration File' ,结果是:

Path => /usr/local/etc Path => / usr / local / etc.

Loaded Configuration File => /usr/local/etc/php.ini 加载的配置文件=> /usr/local/etc/php.ini

But the result of phpinfo() is 但是phpinfo()的结果是

Configuration File (php.ini) Path : /etc 配置文件(php.ini)路径:/ etc

I can copy over php.ini from /usr/local/etc/ to /etc/ , but is it possible to change the php.ini folder? 我可以将php.ini/usr/local/etc/复制到/etc/ ,但是可以更改php.ini文件夹吗?

I installed PHP using homebrew and I am using OS X Snow Leopard. 我使用自制软件安装PHP,我使用的是OS X Snow Leopard。

PHP uses different .ini files when running via command line vs running as a web server module. 当通过命令行运行而不是作为Web服务器模块运行时,PHP使用不同的.ini文件。 When you grep the results of php -i your getting the command line ini. 当你grep php -i的结果你得到命令行ini。 It's good practice to have separate ini's for the two environments. 在两种环境中使用单独的ini是一种很好的做法。

If you must change the directory PHP looks for the php.ini file, you can use the PHPIniDir in your web server conf file. 如果必须更改PHP查找php.ini文件的目录,则可以在Web服务器配置文件中使用PHPIniDir

If you wish to just add additional directories to be scanned, you can set the PHP_INI_SCAN_DIR environment variable. 如果您只想添加要扫描的其他目录,可以设置PHP_INI_SCAN_DIR环境变量。

要更改php.ini文件路径,我们必须在apache配置文件'httpd.conf'语法中声明PHPINIDir,即:

PHPINIDir "path_to_ini_file";

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

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