且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将自定义路径设置为php.ini(不在Apache中)

更新时间:2022-03-21 21:54:29

http: //www.php.net/manual/en/configuration.file.php

在以下位置搜索

php.ini(按顺序):

php.ini is searched in these locations (in order):

  • SAPI模块的特定位置(Apache 2中的PHPIniDir指令,CGI和CLI中的-c命令行选项,NSAPI中的php_ini参数,THTTPD中的PHP_INI_PATH环境变量)

  • SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD)

PHPRC环境变量.在PHP 5.2.0之前,需要在下面提到的注册表项之后对此进行检查.

The PHPRC environment variable. Before PHP 5.2.0 this was checked after the registry key mentioned below.

从PHP 5.2.0开始,可以为不同版本的PHP设置php.ini文件的位置.依次检查以下注册表项:[HKEY_LOCAL_MACHINE \ SOFTWARE \ PHP \ xyz],[HKEY_LOCAL_MACHINE \ SOFTWARE \ PHP \ xy]和[HKEY_LOCAL_MACHINE \ SOFTWARE \ PHP \ x],其中x,y和z表示PHP专业语言,次要版本和发行版本.如果这些键中有IniFilePath的值,则找到的第一个将用作php.ini的位置(仅Windows).

As of PHP 5.2.0, the location of the php.ini file can be set for different versions of PHP. The following registry keys are examined in order: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z], [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where x, y and z mean the PHP major, minor and release versions. If there is a value for IniFilePath in these keys, then the first one found will be used as the location of the php.ini (Windows only).

[HKEY_LOCAL_MACHINE \ SOFTWARE \ PHP],IniFilePath的值(仅Windows).

[HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only).

当前工作目录(CLI除外)

Current working directory (except CLI)

Web服务器的目录(用于SAPI模块),或PHP的目录(在Windows中为其他目录)

The web server's directory (for SAPI modules), or directory of PHP (otherwise in Windows)

Windows目录(对于Windows,是C:\ windows或C:\ winnt),或--with-config-file-path编译时间选项

Windows directory (C:\windows or C:\winnt) (for Windows), or --with-config-file-path compile time option

此外,从PHP 5.3开始,您还可以使用按目录的.ini文件.请参见 http://php.net/manual/zh/configuration.file. per-user.php

In addition as of PHP 5.3, you can use per-directory .ini files. See http://php.net/manual/en/configuration.file.per-user.php