php5 – 在Redhat上是否有相当于Debian的cli / php.ini?

如何配置 PHP的命令行版本以在Redhat系统上进行不同的设置?

在基于Debian的系统上,PHP一个单独的命令行版本配置文件:/ etc / PHP5 / cli.

在Redhat上,在/etc/PHP.d/中有/etc/PHP.ini和各种其他ini文件,但命令行版本没有单独的配置文件,即使安装了PHP-cli软件包.

你有两个选择:

>使用-c参数指示ini文件位置
>在/ etc /上创建一个PHP-cli.ini文件

official PHP manual

The configuration file (PHP.ini) is read when PHP starts up. For the
server module versions of PHP,this happens only once when the web
server is started. For the CGI and CLI versions,it happens on every
invocation.

PHP.ini is searched for in these locations (in order):

  • 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)
  • The PHPRC environment variable. Before PHP 5.2.0,this was checked after the registry key mentioned below.
  • 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 any of these keys,the first one found will be used as the location
    of the PHP.ini (Windows only).
  • [HKEY_LOCAL_MACHINE\SOFTWARE\PHP],value of IniFilePath (Windows only).
  • Current working directory (except CLI).
  • The web server’s directory (for SAPI modules),or directory of PHP (otherwise in Windows).
  • Windows directory (C:\windows or C:\winnt) (for Windows),or –with-config-file-path compile time option.

If PHP-SAPI.ini exists (where SAPI is the SAPI in use,so,for
example,PHP-cli.ini
or PHP-apache.ini),it is used instead of PHP.ini. The SAPI name can be determined with PHP_sapi_name().

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...