Can php.ini file be used at the directory level? [closed]

荒凉一梦 提交于 2019-12-12 04:43:12

问题


I am wondering whether I can use a php.ini file at the directory level? Specifically, I have a domain pointed to a virtual document root in a sub-directory and would like to override some php.ini values previously defined in the php.ini file located in the physical root directory.

Is this possible simply by redefining these values in a new php.ini in the sub-directory? I'm trying to stay away from defining these in .htaccess file.


回答1:


In general no, but in special (CGI/FastCGI) yes: http://php.net/configuration.file.per-user

Since PHP 5.3.0, PHP includes support for .htaccess-style INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are using Apache, use .htaccess files for the same effect.

In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). In case the PHP file is outside the document root, only its directory is scanned.

You can only set a limited subset of the ini-options in the user-ini-file. If you are hosting several independent sites on one server, you should consider FastCGI anyway, to keep them separated. With php5-fpm it's very easy to setup many pools of workers.



来源:https://stackoverflow.com/questions/13536151/can-php-ini-file-be-used-at-the-directory-level

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!