php-doc-en/chapters/config.xml
Gabor Hojtsy c24146d835 Several fixes to the config section:
- fixing PHP 3 and 4 version numbers
 - converting <literal>PHP</literal> to PHP
 - do not suggest a magic_quotes_gpc=yes setting
 - php_value et.al. is compatible with PHP 5
 - use <emphasis> instead of uppercase
 - include PHP 5 Apache setting example
 - move out list of core config directives to the appendix as planned


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@159550 c90b9560-bf6c-de11-be94-00142212c4b1
2004-05-24 21:11:36 +00:00

257 lines
9.3 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.118 $ -->
<chapter id="configuration">
<title>Runtime Configuration</title>
<sect1 id="configuration.file">
<title>The configuration file</title>
<simpara>
The configuration file (called <filename>php3.ini</filename> in
PHP 3, and simply &php.ini; as of PHP 4)
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>CGI</acronym> and <acronym>CLI</acronym> version, it happens on
every invocation.
</simpara>
<para>
The default location of &php.ini; is a compile time option (see the <link
linkend="faq.installation.phpini">FAQ</link> entry), but can be changed
for the <acronym>CGI</acronym> and <acronym>CLI</acronym> version with the
<literal>-c</literal> command line switch, see the chapter about using
PHP from the <link
linkend="features.commandline">command line</link>. You can also use the
environment variable <varname>PHPRC</varname> for an additional path to
search for a &php.ini; file.
</para>
<note>
<para>
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.
</para>
</note>
<para>
The &php.ini; directives handled by extensions are documented respectively
on the pages of the extensions themselfs. The <link linkend="ini">list of
the core directives</link> is available in the appendix. Probably not all
the PHP directives are documented in the manual though. For a completel list
of directives available in your PHP version, please read your well commented
&php.ini; file. Alternatively, you may find the
<ulink url="&url.php.cvs.phpini;">the latest &php.ini;</ulink> from CVS
helpful too.
</para>
<para>
<example>
<title>&php.ini; example</title>
<programlisting role="ini">
<![CDATA[
; 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"
]]>
</programlisting>
<!-- TODO: add more details about values and expressions -->
</example>
</para>
</sect1>
<sect1 id="configuration.changes">
<title>How to change configuration settings</title>
<sect2 id="configuration.changes.apache">
<title>Running PHP as an Apache module</title>
<simpara>
When using PHP as an Apache module, you can also change the
configuration settings using directives in Apache configuration
files (e.g. &httpd.conf;) and &htaccess; files. You will need
"AllowOverride Options" or "AllowOverride All" privileges to do so.
</simpara>
<para>
With PHP 4 and PHP 5, there are several Apache directives that allow you
to change the PHP configuration from within the Apache configuration
files. For a listing of which directives are
<constant>PHP_INI_ALL</constant>, <constant>PHP_INI_PERDIR</constant>,
or <constant>PHP_INI_SYSTEM</constant>, have a look at the table
found within the <function>ini_set</function> documentation.
</para>
<note>
<simpara>
With PHP 3, there are Apache directives that correspond to each
configuration setting in the <filename>php3.ini</filename> name,
except the name is prefixed by "php3_".
</simpara>
</note>
<para>
<variablelist>
<varlistentry>
<term>
<systemitem role="directive">php_value</systemitem>
<parameter>name</parameter>
<parameter>value</parameter>
</term>
<listitem>
<para>
Sets the value of the specified directive.
Can be used only with <constant>PHP_INI_ALL</constant> and <constant>PHP_INI_PERDIR</constant> type directives.
To clear a previously set value use <literal>none</literal> as the value.
</para>
<note>
<simpara>
Don't use <systemitem role="directive">php_value</systemitem> to set boolean values.
<systemitem role="directive">php_flag</systemitem> (see below) should be used instead.
</simpara>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term>
<systemitem role="directive">php_flag</systemitem>
<parameter>name</parameter>
<parameter>on|off</parameter>
</term>
<listitem>
<para>
Used to set a boolean configuration directive.
Can be used only with <constant>PHP_INI_ALL</constant> and
<constant>PHP_INI_PERDIR</constant> type directives.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<systemitem role="directive">php_admin_value</systemitem>
<parameter>name</parameter>
<parameter>value</parameter>
</term>
<listitem>
<para>
Sets the value of the specified directive.
This <emphasis>can not be used</emphasis> in &htaccess; files.
Any directive type set with <systemitem role="directive">php_admin_value</systemitem>
can not be overridden by &htaccess; or virtualhost directives.
To clear a previously set value use <literal>none</literal> as the value.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<systemitem role="directive">php_admin_flag</systemitem>
<parameter>name</parameter>
<parameter>on|off</parameter>
</term>
<listitem>
<para>
Used to set a boolean configuration directive.
This <emphasis>can not be used</emphasis> in &htaccess; files.
Any directive type set with <systemitem role="directive">php_admin_flag</systemitem>
can not be overridden by &htaccess; or virtualhost directives.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<example>
<title>Apache configuration example</title>
<programlisting role="ini">
<![CDATA[
<IfModule mod_php5.c>
php_value include_path ".:/usr/local/lib/php"
php_admin_flag safe_mode on
</IfModule>
<IfModule mod_php4.c>
php_value include_path ".:/usr/local/lib/php"
php_admin_flag safe_mode on
</IfModule>
<IfModule mod_php3.c>
php3_include_path ".:/usr/local/lib/php"
php3_safe_mode on
</IfModule>
]]>
</programlisting>
</example>
</para>
<caution>
<para>
PHP constants do not exist outside of PHP. For example, in
&httpd.conf; you can not use PHP constants
such as <constant>E_ALL</constant> or <constant>E_NOTICE</constant>
to set the <link linkend="ini.error-reporting">error_reporting</link>
directive as they will have no meaning and will evaluate to
<emphasis>0</emphasis>. Use the associated bitmask values instead.
These constants can be used in &php.ini;
</para>
</caution>
</sect2>
<sect2 id="configuration.changes.windows">
<title>Changing PHP configuration via the Windows registry</title>
<simpara>
When running PHP on Windows, the configuration values can be
modified on a per-directory basis using the Windows registry. The
configuration values are stored in the registry key
<literal>HKLM\SOFTWARE\PHP\Per Directory Values</literal>,
in the sub-keys corresponding to the path names. For example, configuration
values for the directory <literal>c:\inetpub\wwwroot</literal> would
be stored in the key <literal>HKLM\SOFTWARE\PHP\Per Directory
Values\c\inetpub\wwwroot</literal>. The settings for the
directory would be active for any script running from this
directory or any subdirectory of it. The values under the key
should have the name of the PHP configuration directive and the
string value. PHP constants in the values are not parsed.
</simpara>
</sect2>
<sect2 id="configuration.changes.other">
<title>Other interfaces to PHP</title>
<para>
Regardless of how you run PHP, you can change certain values at runtime
of your scripts through <function>ini_set</function>. See the documentation
on the <function>ini_set</function> page for more information.
</para>
<para>
If you are interested in a complete list of configuration settings
on your system with their current values, you can execute the
<function>phpinfo</function> function, and review the resulting
page. You can also access the values of individual configuration
directives at runtime using <function>ini_get</function> or
<function>get_cfg_var</function>.
</para>
</sect2>
</sect1>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->