downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Описание встроенных директив php.ini> <Список директив php.ini
[edit] Last updated: Fri, 25 May 2012

view this page in

Список разделов php.ini

В этом списке указаны разделы, в которых вы можете настроить PHP в зависимости от хоста или пути. Эти разделы необязательны.

Данные разделы не имеют прямого влияния на PHP. Они нужны для группировки других директив php.ini вместе и для возможности действовать в зависимости от определенного хоста или пути.

Данные разделы используются только в режиме CGI/FastCGI и в них не могут быть использованы директивы extension и zend_extension.

Разделы
Название Место изменения История изменений
[HOST=] PHP_INI_SYSTEM Добавлено в PHP 5.3.0.
[PATH=] PHP_INI_SYSTEM Добавлено в PHP 5.3.0.

Краткое разъяснение конфигурационных директив.

[HOST=<host>]

Данный раздел позволяет определять набор php.ini директив, которые будут применяться только к указанному хосту.

Пример #1 Активация полного логирования и сообщения об ошибках для dev. домена

[HOST=dev.site.com]
error_reporting = E_ALL
display_errors = On

[PATH=<path>]

Данный раздел позволяет определять набор php.ini директив, которые будут применяться, если скрипт будет запущен из указанного пути.

Пример #2 Добавление скрипта безопасности для защищенных зон

[PATH=/home/site/public/secure]
auto_prepend_file=security.php



add a note add a note User Contributed Notes Список разделов php.ini
Asad 11-Mar-2012 04:27
Important thing to note:

Directives set in these sections cannot be overridden by user-defined INI files or at runtime.
z dot himdi at bita dot nl 04-Aug-2011 07:53
On Windows IIS 7 server I noticed that [PATH=] was not listened to. [HOST=] however worked.
leo 06-May-2011 03:21
Just developed the probably first php.ini hack to add commands which will only be parsed before PHP 5.3 when using mod_php.

<?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.
[HOST=*]
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:

http://www.php.net/manual/en/ini.sections.php

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".
stickman 05-Jan-2011 01:39
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).
crash at lubyte dot de 06-Sep-2010 05:45
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:
[HOST=dev.example.com]
display_errors = on

[PHP]

this will change the section back to [PHP] where extension= and zend_extension= is allowed.
robert dot johnson at icap dot com 12-Apr-2010 10:26
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.
public at grik dot net 24-Sep-2009 03:00
In [HOST=...] one should use only the 1st server name from the list of server names.

I.E. if you have
server_name example.com, example2.com;
and will use www.example.com in a browser,
use [HOST=example.com] 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).

 
show source | credits | stats | sitemap | contact | advertising | mirror sites