Controlling PHP - php.ini
(Page 2 of 6 )
One way in which the behavior of PHP can be modified is through it's main configuration file, php.ini. While PHP will happily run without it, it's a good to be use this file to fine tune your PHP installation.
PHP first looks in the current working directory for php.ini. If it's not found in the current directory, PHP then looks to the default path for the configuration file. The default path is /usr/local/lib but can be changed at compile time using the --with-config-file-path option.
If PHP runs as an Apache module, because it's loaded when Apache starts and remains in memory then php.ini will only be parsed once. Configuration changes require Apache to be restarted.
In contrast, if PHP runs as a standalone interpreter for CGI scripts then php.ini is parsed each time the PHP processor is loaded (each time a script is called). No other services need to be reloaded for the changes to take effect.
The php.ini file is not installed by default. Instead, there are two copies in the source directory that may be copied and renamed: php.ini-recommended and php.ini-dist. The first one is geared more towards controlling PHP's behavior to provide a development environment while the later is sets options suitable for a production environment.
php.ini uses the semicolon to denote comments. Any line beginning with a semicolon, or any text following a semicolon up until the end of the line will be ignored when the file is parsed.
Various configuration options that are related to one another are grouped and labeled with section markers. These section markers appear in square braces and are also ignored.
Here is a simplified excerpt from the php.ini-recommended file:
[PHP] ; Enable the PHP scripting language engine under Apache engine = On
; Allow ASP-style <% %> tags asp_tags = Off
; The number of significant digits displayed in floating ; point numbers precision = 14 |
The PHP section marker shows that the following directives are global options that affect the overall operation of PHP (as opposed to more specialized options which affect specific modules and extensions).
Informational comments explain the various options. They're there just for the sake of convenience and are ignored by PHP when it parses the configuration file.
The actual configuration option consists of two parts: the directive and it's value. Some directives are boolean in nature and can either be set to on or off. Others can be set to string or integer values.
Next: httpd.conf >>
More Miscellaneous Articles
More By bluephoenix