PHP 5.6.14 is available

php.ini のセクション一覧

この一覧では、ホスト単位やパス単位で PHP の設定を行いたい場合に設定する php.ini のセクションをまとめます。これらのセクションはオプションです。

これらのセクションは、PHP に直接影響を及ぼすわけではありません。 さまざまな php.ini ディレクティブをひとまとめにして、 それを特定のホストや特定のパスにだけ適用する場合に使用します。

これらのセクションは CGI/FastCGI モードでのみ使用します。 extension および zend_extension ディレクティブは設定できません。

名前 変更可能 変更履歴

以下に設定ディレクティブに関する 簡単な説明を示します。


このセクションで指定した php.ini ディレクティブは、 指定した名前のホスト上でのみ有効となります。

例1 dev. ドメインではエラーを画面に表示させるようにする例

error_reporting = E_ALL
display_errors = On


このセクションで指定した php.ini ディレクティブは、 指定したパスで実行したスクリプトでのみ有効となります。

例2 保護エリア内でのスクリプトのセキュリティ確保


add a note add a note

User Contributed Notes 6 notes

z dot himdi at bita dot nl
4 years ago
On Windows IIS 7 server I noticed that [PATH=] was not listened to. [HOST=] however worked.
4 years ago
Just developed the probably first php.ini hack to add commands which will only be parsed before PHP 5.3 when using mod_php.


# Disable eAccelerator by default
eaccelerator.enable = 0

# Now, to prevent incompatibilities with Zend Optimizer+, we
# want to enable eAccelerator only in PHP 5.2 or lower.
eaccelerator.enable = 1


What is happening here? In PHP 5.3, php.ini sections to set up PHP on a per host basis have been introduced:

These sections only work in CGI/FastCGI mode, however there still seems to be a difference in how the php.ini file is parsed in PHP 5.2 and PHP 5.3 when using mod_php: PHP 5.3 ignores everything below the line [HOST=*], whereas PHP 5.2 does not.

In the above example, PHP 5.3 only reads "eaccelerator.enable = 0" and then stops at the invalid command [HOST=*]. However, PHP 5.2 seems to ignore the invalid command and parses the whole configuration file, ending up with "eaccelerator.enable = 1".
public at grik dot net
6 years ago
In [HOST=...] one should use only the 1st server name from the list of server names.

I.E. if you have
and will use in a browser,
use [] in php.ini for both addresses.

PHP looks not at the HOST request header (as I expected), but at the SERVER_NAME parameter (which by default is the 1st from the list of names, no matter what the HOST is).
4 years ago
This doesn't seem to work with php-fpm.
The values defined under PATH or HOST will become the new master value for all the processes (as if they were redefined).
robert dot johnson at icap dot com
5 years ago
Adding PATH= applies only to the named path and does not include sub-directories, you have to add a PATH= value for each sub-directory.

Also some settings have no effect even though phpinfo recognises and displays the per-folder value as the 'local' value, and the default as the 'master' value.

'fastcgi.impersonate' always uses the master setting.
crash at lubyte dot de
5 years ago
If you have a system which uses separated PHP inis for loading extensions (Debian, Fedora and most other distributions do so), [PATH=] or [HOST=] will prevent loading extensions defined in those ini files (extension= and zend_extension=).

I had some headache, when I added a hosts.ini to /etc/php5/cgi/conf.d (Debians default), where I wanted to define some defaults for a host name. The manual says extension= and zend_extension= aren't allowed in [HOST=] and [PATH=] (see above). I figured out that you can easily fix that with adding [PHP] after your definitions.

For example hosts.ini:
display_errors = on


this will change the section back to [PHP] where extension= and zend_extension= is allowed.
To Top