Source of: /manual/en/configuration.file.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/configuration.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'configuration.file.php',
1 => 'The configuration file',
),
'up' =>
array (
0 => 'configuration.php',
1 => 'Runtime Configuration',
),
'prev' =>
array (
0 => 'configuration.php',
1 => 'Runtime Configuration',
),
'next' =>
array (
0 => 'configuration.file.per-user.php',
1 => '.user.ini files',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="configuration.file" class="sect1">
<h2 class="title">The configuration file</h2>
<p class="simpara">
The configuration file (<var class="filename">php.ini</var>)
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
<acronym title="Common Gateway Interface">CGI</acronym> and <acronym title="Command Line Interpreter/Interface">CLI</acronym> version, it happens on
every invocation.
</p>
<p class="para">
<var class="filename">php.ini</var> is searched in these locations (in order):
</p><ul class="itemizedlist">
<li class="listitem">
<p class="para">
SAPI module specific location (<i>PHPIniDir</i> directive
in Apache 2, <i>-c</i> command line option in CGI and CLI,
<i>php_ini</i> parameter in NSAPI,
<i>PHP_INI_PATH</i> environment variable in THTTPD)
</p>
</li>
<li class="listitem">
<p class="para">
The <var class="varname">PHPRC</var> environment variable. Before PHP 5.2.0
this was checked after the registry key mentioned below.
</p>
</li>
<li class="listitem">
<p class="para">
As of PHP 5.2.0, the location of the <i>php.ini</i> file
can be set for different versions of PHP. The following registry keys
are examined in order:
<i>[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z]</i>,
<i>[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y]</i> and
<i>[HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x]</i>, where
x, y and z mean the PHP major, minor and release versions. If there is a
value for <i>IniFilePath</i> in these keys, then the first
one found will be used as the location of the <i>php.ini</i> (Windows only).
</p>
</li>
<li class="listitem">
<p class="para">
<i>[HKEY_LOCAL_MACHINE\SOFTWARE\PHP]</i>, value of
<i>IniFilePath</i> (Windows only).
</p>
</li>
<li class="listitem">
<p class="para">
Current working directory (except CLI)
</p>
</li>
<li class="listitem">
<p class="para">
The web server's directory (for SAPI modules), or directory of PHP
(otherwise in Windows)
</p>
</li>
<li class="listitem">
<p class="para">
Windows directory (<var class="filename">C:\windows</var>
or <var class="filename">C:\winnt</var>) (for Windows), or
<i>--with-config-file-path</i> compile time option
</p>
</li>
</ul><p>
</p>
<p class="para">
If <var class="filename">php-SAPI.ini</var> exists (where SAPI is used SAPI, so the
filename is e.g. <var class="filename">php-cli.ini</var> or
<var class="filename">php-apache.ini</var>), it's used instead of <var class="filename">php.ini</var>.
SAPI name can be determined by <a href="function.php-sapi-name.php" class="function">php_sapi_name()</a>.
</p>
<blockquote><p><b class="note">Note</b>:
The Apache web server changes the directory to root at startup causing
PHP to attempt to read <var class="filename">php.ini</var> from the root filesystem if it exists.
<br />
</p></blockquote>
<p class="para">
The <var class="filename">php.ini</var> directives handled by extensions are documented respectively
on the pages of the extensions themselves. The <a href="ini.php" class="link">list of
the core directives</a> is available in the appendix. Probably not all
PHP directives are documented in the manual though. For a complete list
of directives available in your PHP version, please read your well commented
<var class="filename">php.ini</var> file. Alternatively, you may find the
<a href="http://svn.php.net/viewvc/php/php-src/trunk/php.ini-production?view=co" class="link external">» the latest <var class="filename">php.ini</var></a> from SVN
helpful too.
</p>
<p class="para">
</p><div class="example">
<p><b>Example #1 <var class="filename">php.ini</var> example</b></p>
<div class="example-contents programlisting">
<div class="inicode"><pre class="inicode">; 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"</pre>
</div>
</div>
</div><p>
</p>
<p class="para">
Since PHP 5.1.0, it is possible to refer to existing .ini variables from
within .ini files. Example: <i>open_basedir = ${open_basedir}
":/new/dir"</i>.
</p>
</div><?php manual_footer(); ?>