更改php.ini的位置 [英] Change php.ini location
问题描述
是否可以更改php.ini
的位置以供Apache使用?当我做php -i | grep 'Configuration File'
时,结果是:
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:
路径=>/usr/local/etc
Path => /usr/local/etc
已加载的配置文件=>/usr/local/etc/php.ini
Loaded Configuration File => /usr/local/etc/php.ini
但是phpinfo()
的结果是
配置文件(php.ini)路径:/etc
Configuration File (php.ini) Path : /etc
我可以将php.ini
从/usr/local/etc/
复制到/etc/
,但是可以更改php.ini文件夹吗?
I can copy over php.ini
from /usr/local/etc/
to /etc/
, but is it possible to change the php.ini folder?
我使用自制软件安装了PHP,并且正在使用OS X Snow Leopard.
I installed PHP using homebrew and I am using OS X Snow Leopard.
推荐答案
通过命令行运行与作为Web服务器模块运行时,PHP使用不同的.ini
文件. grep php -i
的结果时,将获得命令行ini.最好在两种环境中使用单独的ini.
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.
如果必须更改目录,PHP将查找php.ini
文件,则可以在Web服务器conf文件中使用PHPIniDir
.
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_INI_SCAN_DIR
环境变量.
If you wish to just add additional directories to be scanned, you can set the PHP_INI_SCAN_DIR
environment variable.
这篇关于更改php.ini的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!