File: ini.xml

package info (click to toggle)
php-doc 20081024-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 57,752 kB
  • ctags: 3,858
  • sloc: xml: 686,554; php: 19,446; perl: 610; cpp: 500; makefile: 336; sh: 114; awk: 28
file content (301 lines) | stat: -rw-r--r-- 11,076 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.21 $ -->
 <chapter xml:id="configuration" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
  <title>Runtime Configuration</title>

  <sect1 xml:id="configuration.file">
   <title>The configuration file</title>

   <simpara>
    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
    <acronym>CGI</acronym> and <acronym>CLI</acronym> version, it happens on
    every invocation.
   </simpara>
   <para>
    &php.ini; is searched in these locations (in order):
    <itemizedlist>
     <listitem>
      <para>
       SAPI module specific location (<literal>PHPIniDir</literal> directive
       in Apache 2, <literal>-c</literal> command line option in CGI and CLI,
       <literal>php_ini</literal> parameter in NSAPI,
       <literal>PHP_INI_PATH</literal> environment variable in THTTPD)
      </para>
     </listitem>
     <listitem>
      <para>
       The <varname>PHPRC</varname> environment variable. Before PHP 5.2.0
       this was checked after the registry key mentioned below.
      </para>
     </listitem>
     <listitem>
      <para>
       As of PHP 5.2.0, the following registry locations are searched in
       order:
       <literal>HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z\IniFilePath</literal>,
       <literal>HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y\IniFilePath</literal> and
       <literal>HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x\IniFilePath</literal>, where
       x, y and z mean the PHP major, minor and release versions.
      </para>
     </listitem>
     <listitem>
      <para>
       <literal>HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath</literal>
       (Windows Registry location)
      </para>
     </listitem>
     <listitem>
      <para>
       Current working directory (except CLI)
      </para>
     </listitem>
     <listitem>
      <para>
       The web server's directory (for SAPI modules), or directory of PHP
       (otherwise in Windows)
      </para>
     </listitem>
     <listitem>
      <para>
       Windows directory (<filename class="directory">C:\windows</filename>
       or <filename class="directory">C:\winnt</filename>) (for Windows), or
       <literal>--with-config-file-path</literal> compile time option
      </para>
     </listitem>
    </itemizedlist> 
   </para>
   <para>
    If <filename>php-SAPI.ini</filename> exists (where SAPI is used SAPI, so the
    filename is e.g. <filename>php-cli.ini</filename> or
    <filename>php-apache.ini</filename>), it's used instead of &php.ini;.
    SAPI name can be determined by <function>php_sapi_name</function>.
   </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 themselves. The <link linkend="ini">list of
    the core directives</link> 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
    &php.ini; file. Alternatively, you may find the
    <link xlink:href="&url.php.cvs.phpini;">the latest &php.ini;</link> 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>
   <para>
    Since PHP 5.1.0, it is possible to refer to existing .ini variables from
    within .ini files. Example: <literal>open_basedir = ${open_basedir}
    ":/new/dir"</literal>.
   </para>
  </sect1>

  <sect1 xml:id="configuration.changes">
   <title>How to change configuration settings</title>

   <sect2 xml: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>
     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
     <link linkend="ini.list">List of php.ini directives</link> appendix.
    </para>

    <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;.
         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;.
        </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>
]]>
      </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 xml: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. 
      However, only configuration values changeable in 
      <constant>PHP_INI_USER</constant> can be set
      this way, <constant>PHP_INI_PERDIR</constant> values can not.
     </simpara>
   </sect2>
   
   <sect2 xml: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
-->