PhpIniDir的应用 php源程序中 php.ini-dist和php.ini-recommended的区别

本文详细解析了PHPIniDir的应用及其在不同环境下的查找路径,同时比较了php.ini-dist与php.ini-recommended的区别,强调了后者在安全性和效率方面的优势,建议开发者在部署应用时使用推荐版进行配置。
PhpIniDir的应用(转载)

PhpIniDir是PHP的初始化文件php.ini的路径,过去大家将php.ini放在windows目录下,在PHP5中,PHP.ini的查找路径不再限于PHP4时代的%SystemRoot%,PHP5会按以下顺序查找PHP.ini:

1、PHPIniDir(Apache 2 module only,这个指令仅仅用于当PHP作为Apache模块时使用,不支持CGI运行的PHP)
2、注册表键值:HKEY_LOCAL_MACHINE/SOFTWARE/PHP/IniFilePath
3、环境变量:%PHPRC%
4、PHP5的目录(for CLI),或者web服务器目录(for SAPI modules)
5、Windows目录(C:/windows or C:/winnt)

这五个方案中,配合Apache2时最好使用PHPIniDir,即在apache2/conf/httpd.conf文件中加入:

# configure the path to php.ini
PHPIniDir " C:/php"

另外,NTFS上记得给服务器开PHP.ini的读权限。
[b][color=green]===============================================================================[/color][/b]
附:php.ini-dist与php.ini-recommended的区别

根据php.ini-dist的说明,二者不同之处在于[color=green][b]php.ini-dist适合开发程序使用[/b][/color],而[color=green][b]php.ini-recommended 拥有较高的安全性设定,适合上线当产品使用[/b][/color]。因此,出于安全和效率的考虑,建议使用php.ini-recommended作为php.ini的蓝本,而 不要使用php.ini-dist。

官方说明如下:

This is the default settings file for new PHP installations.
By default, PHP installs itself with a configuration suitable for development purposes, and *NOT* for production purposes.
For several security-oriented considerations that should be taken before going online with your site, please consult php.ini-recommended and http://php.net/manual/en/security.php.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值