Php ini file extension

Php ini file extension

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

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

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

Разделы

Название Место изменения История изменений
[HOST=] PHP_INI_SYSTEM
[PATH=] PHP_INI_SYSTEM

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

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

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

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

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

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

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

User Contributed Notes 8 notes

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).

Sorry for the note. I’ve read some bad tutorials.
The correct syntax is : directive = ‘value’
not a thing like : php_value[directive] = «somevalue»

this HOST and PATH sections doesn’t seems to work in php.ini under apache 2.4 with php-fpm 7.1.16 for directive php_value or php_admin_value open_basedir or include_path.
phpinfo() says «none» in master and local values.

Note that you cannot usefully set syslog.* in [PATH=] (and probably [HOST=]) sections, since the syslogger is initialized only once per php-fpm worker process, and not per request.

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.
[ 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:

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.

Читайте также:  Java hotspot source code

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».

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

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

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.

Источник

Php ini file extension

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.

  • SAPI module specific location ( PHPIniDir directive in Apache 2, -c command line option in CGI and CLI)
  • The PHPRC environment variable.
  • The location of the php.ini file can be set for different versions of PHP. The root of the registry keys depends on 32- or 64-bitness of the installed OS and PHP. For 32-bit PHP on a 32-bit OS or a 64-bit PHP on a 64-bit OS use [(HKEY_LOCAL_MACHINE\SOFTWARE\PHP] for 32-bit version of PHP on a 64-bit OS use [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\PHP] ] instead. For same bitness installation 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. For 32 bit versions of PHP on a 64 bit OS the following registry keys are examined in order: [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x.y.z] , [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\PHP\x.y] and [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6421Node\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] or [HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\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.
Читайте также:  Python numpy ndarray object is not callable

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() .

Note:

The Apache web server changes the directory to root at startup, causing PHP to attempt to read php.ini from the root filesystem if it exists.

Using environment variables can be used in php.ini as shown below.

Example #1 php.ini Environment Variables

; PHP_MEMORY_LIMIT is taken from environment memory_limit = $

The php.ini directives handled by extensions are documented on the respective pages of the extensions themselves. A list of the core directives is available in the appendix. Not all PHP directives are necessarily documented in this manual: for a complete list of directives available in your PHP version, please read your well commented php.ini file. Alternatively, you may find » the latest php.ini from Git helpful too.

Example #2 php.ini example

; any text on a line after an unquoted semicolon (;) is ignored [php] ; section markers (text within square brackets) are also ignored ; Boolean values can be set to either: ; true, on, yes ; or false, off, no, none register_globals = off track_errors = yes ; you can enclose strings in double-quotes include_path = ".:/usr/local/lib/php" ; backslashes are treated the same as any other character include_path = ".;c:\php\lib"

It is possible to refer to existing .ini variables from within .ini files. Example: open_basedir = $ «:/new/dir» .

Scan directories

It is possible to configure PHP to scan for .ini files in a directory after reading php.ini . This can be done at compile time by setting the —with-config-file-scan-dir option. The scan directory can then be overridden at run time by setting the PHP_INI_SCAN_DIR environment variable.

It is possible to scan multiple directories by separating them with the platform-specific path separator ( ; on Windows, NetWare and RISC OS; : on all other platforms; the value PHP is using is available as the PATH_SEPARATOR constant). If a blank directory is given in PHP_INI_SCAN_DIR , PHP will also scan the directory given at compile time via —with-config-file-scan-dir.

Within each directory, PHP will scan all files ending in .ini in alphabetical order. A list of the files that were loaded, and in what order, is available by calling php_ini_scanned_files() , or by running PHP with the —ini option.

Assuming PHP is configured with --with-config-file-scan-dir=/etc/php.d, and that the path separator is . $ php PHP will load all files in /etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d php PHP will load all files in /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=:/usr/local/etc/php.d php PHP will load all files in /etc/php.d/*.ini, then /usr/local/etc/php.d/*.ini as configuration files. $ PHP_INI_SCAN_DIR=/usr/local/etc/php.d: php PHP will load all files in /usr/local/etc/php.d/*.ini, then /etc/php.d/*.ini as configuration files.

Источник

Читайте также:  Указание путей в php

Php ini file extension

On Windows, you have two ways to load a PHP extension: either compile it into PHP, or load the DLL. Loading a pre-compiled extension is the easiest and preferred way.

To load an extension, you need to have it available as a «.dll» file on your system. All the extensions are automatically and periodically compiled by the PHP Group (see next section for the download).

To compile an extension into PHP, please refer to building from source documentation.

To compile a standalone extension (aka a DLL file), please refer to building from source documentation. If the DLL file is available neither with your PHP distribution nor in PECL, you may have to compile it before you can start using the extension.

Where to find an extension?

PHP extensions are usually called «php_*.dll» (where the star represents the name of the extension) and they are located under the «PHP\ext» folder.

PHP ships with the extensions most useful to the majority of developers. They are called «core» extensions.

However, if you need functionality not provided by any core extension, you may still be able to find one in » PECL. The PHP Extension Community Library (PECL) is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.

If you have developed an extension for your own uses, you might want to think about hosting it on PECL so that others with the same needs can benefit from your time. A nice side effect is that you give them a good chance to give you feedback, (hopefully) thanks, bug reports and even fixes/patches. Before you submit your extension for hosting on PECL, please read » PECL submit.

Which extension to download?

  • Different version numbers (at least the first two numbers should match)
  • Different thread safety settings
  • Different processor architecture (x86, x64, . )
  • Different debugging settings
  • etc.

You should keep in mind that your extension settings should match all the settings of the PHP executable you are using. The following PHP script will tell you all about your PHP settings:

Example #1 phpinfo() call

Or from the command line, run:

Источник

Оцените статью