Home  >  Article  >  Backend Development  >  PhpIniDir的使用 php源程序中 php.ini-dist和php.ini-recommended的区别

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

WBOY
WBOYOriginal
2016-06-13 13:25:091003browse

PhpIniDir的应用 php源程序中 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的读权限。
===============================================================================
附:php.ini-dist与php.ini-recommended的区别

根据php.ini-dist的说明,二者不同之处在于php.ini-dist适合开发程序使用,而php.ini-recommended 拥有较高的安全性设定,适合上线当产品使用。因此,出于安全和效率的考虑,建议使用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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn