PHP Configuration Directives

PHP Configuration Directives
==========================================
output_buffering

One of the newest (and greatest) features of PHP is the ability to send header lines anywhere within a script. This directive turns on output buffering for all files. You should probably leave this set to “off” because calling one of the output buffering functions of PHP will work regardless.
Example:
Turn on output buffering.
output_buffering = On

implicit_flush

This directive is used mainly for debugging purposes because of performance. Used with output_buffering it is equivalent to calling the flush() function after every print(), echo(), and HTML block.
Example:
Turn off implicit flushing of output buffers.
implicit_flush = Off

safe_mode

When PHP is used as a CGI this will ensure that the user can only access information contained in the document root.
Example:
Turn off safe mode.
safe_mode = Off

safe_mode_allowed_env_vars

This allows you to set a prefix to any environmental variables ensuring that only variables you accept can be accessed/set. Multiple prefixes can be set as a comma-delimited list.
Example:
Only allow PHP and HTTP environmental variables.
safe_mode_allowed_env_vars = PHP_, HTTP_

safe_mode_protected_env_vars

Allows you to define, by a comma-delimited list, any environmental variables that can never be changed.
Example:
Protect all HTTP environmental variables.
safe_mode_protected_env_vars = HTTP_

disable_functions

Allows you to define a comma-delimited list of functions to be disabled within PHP.
Example:
Disable certain file-related functions.
disable_functions = fopen, fwrite, popen

max_execution_time

Maximum time a PHP script will execute before timing out. Even if this is set to “off”, the execution time can be defined on a per-script basis using the set_time_limit() function.
Example:
Set maximum execution time to 1 minute.
max_execution_time = 60

memory_limit

Maximum amount of memory a PHP script can consume.
Example:
Limit memory to approximately 8 Mbits.
memory_limit = 8388608

error_reporting

This is a bit-field or named constant directive with the following bit levels added to determine the verbosity of PHP errors.

1  -  E_ERROR    Normal errors
2  -  E_WARNING  Normal warnings
4  -  E_PARSE    Parser errors
8  -  E_NOTICE   Non-critical style-related errors

Example:
Only report the three most critical errors.
error_reporting = E_ERROR | E_WARNING | E_PARSE
Show all errors except notices (shorthand for above example)
error_reporting = E_ALL & ~E_NOTICE

display_errors

This will cause PHP to print out the errors along with the HTML. Helpful for debugging.
Example:
Display errors to the screen.
display_errors = On

log_errors

This directive causes PHP to store errors in a log file which can be defined with the error_log directive.
Example:
Log all errors to a log file.
log_errors = On

track_errors

Stores the last error/warning message in a PHP variable called $php_errormsg.
Example:
Enable the tracking of last error/warning message.
track_errors = On

error_prepend_string

String to output before an error message. This is handy if you want to make all of your errors highlighted in red, for example.
Example:
Highlight all errors in red.
error_prepend_string = "<span style='color: red;'>"

error_append_string

The opposite of error_prepend_string.
Example:
error_append_string = "</span>"

error_log

The directive defines which file you would like PHP to use to log errors. If you want errors to be logged with syslog, you can give the value “syslog” (less the quotes). If you’re using NT, this will log errors in the Event Log.
Example:
Log all errors to ‘/var/log/my_php_errors.log’
error_log = /var/log/my_php_errors.log

track_vars

This turns on $HTTP_GET_VARS, $HTTP_POST_VARS, and $HTTP_COOKIE_VARS arrays.
Example:
Enable track variables.
track_vars = On

magic_quotes_gpc

Turns on magic quotes (escapes single quotes, double quotes, null, and backslash characters) for GET, POST, and cookie data.
Example:
Enable magic quotes.
magic_quotes_gpc = On

magic_quotes_runtime

Automatically escape data generated externally.
Example:
Disable magic quotes runtime.
magic_quotes_runtime = Off

magic_quotes_sybase

In addition to escaping with the standard backslash character (\) this tells PHP to use a single quote as an escape character for Sybase-related escapes.
Example:
Disable magic quotes for Sybase.
magic_quotes_sybase = Off

auto_prepend_file

This tells PHP to automatically tack on the file defined with this directive to the beginning of any file parsed by the PHP engine. This is very useful for defining global variables and making database connections.
Example:
Automatically prepend the file pre.php.
auto_prepend_file = pre.php

auto_append_file

This tells PHP to automatically tack on the file defined with this directive to the end of any file parsed by the PHP engine.
Example:
Automatically append the file post.php.
auto_append_file = post.php

default_charset

Customize the character set of PHP parsed pages.
Example:
Set the default charicter set to Latin-1.
default_charset = "iso-8859-1"

include_path

This tells PHP where to look when the include() and require() functions are used. The format for Unix is just like that of the PATH environmental variable. This is pretty much the same on Windows except that the colon is replaced with a semicolon.
Example:
Set the include path to be the current directiory and /usr/local/lib/php.
include_path = .:/usr/local/lib/php
Windows version of the above example.
include_path = .;/usr/local/lib/php

upload_tmp_dir

This defines where PHP will store uploaded files temporarily until the user can move them to a more permanent location.
Example:
Store all uploaded files in /tmp.
upload_tmp_dir = /tmp

upload_max_filesize

The maximum file size that can be uploaded through PHP.
Example:
Set the maximum uploaded file size to be 2 Mbits.
upload_max_filesize = 2097152

extension_dir

This defines the location where loadable module extensions reside.
Example:
Set the current working directory as the extension directory.
extension_dir = ./

enable_dl

This enables/disables the ability to dynamically load a PHP module extension. This doesn’t work properly on multithreaded servers so it is disabled by default on those systems.
Example:
Enable dynamically loadable modules.
enable_dl = On

extension

This directive defines a dynamically loadable module extension that PHP should load when starting up. This directive can be used any number of times for each extension that you need to load.
Example:
Enable dynamic loading of the mSQL module.
extension = msql.so
==========================================

Leave a Comment