Tuesday, January 3, 2012

PHP - php.ini explained

PHP.ini is very useful and it is a configuration file that is used to customize behavior of PHP at runtime. This enables easy administration in the way you administer Apache web server using configuration files. The Settings in which  upload directory, register global variables, display errors, log errors, max uploading size setting, maximum time to execute a script and other configurations is written in this file.

When PHP Server starts up it looks for PHP.ini file first to load various values for settings. If you made changes in PHP.ini then you need to restart your server to check the changes be effected.

The major configuration parameters in php.ini as follows

short_open_tag=<On|Off>The short open tag <? instead of <?php.
If you run old applications, enable this; this may cause confusion if other language processors like XML, etc, are present.
output_buffering=<Off|Integer|On>Maximum output data buffer size before sending to client. On enables infinite buffer size (dangerous!). Best value: 4096.
zlib.output_compression=<Off|On>Enables/disables gzip compression of output.
max_execution_time=<Integer>Maximum script execution time (in seconds), set to 0 for CLI. Should be set after trial and error, though 30-60 seconds should be good for standard applications. A very large value is dangerous; a script can hog resources for a long time.
max_input_time=<Integer>Maximum time a script can spend parsing request data. Default is unlimited (-1) [hard-coded for CLI].
memory_limit=<size>Maximum memory a script may consume; size defaults to bytes, but modifiers like M, G can be applied, like 128 M. Keep it so that malicious scripts don’t hog all available memory. 128-256 M is sufficient.
error_reportingSets the type of errors reported to stdout, stderr or the error log. Default value: E_ALL & ~E_NOTICE. Production value: E_ALL & ~E_DEPRECATED. Development value: E_ALL | ~E_STRICT
display_errors=<Off|On|stderr>Displays errors to stdout or stderr. Stderr affects only CLI and CGI binaries.
include_path=<paths separated by colon>Colon-separated paths for PHP to search for files named in include, require, include_once or require_once.
file_uploads = <Off|On>Enables/disables file uploads.
upload_max_filesize=<size>Maximum file-size for file upload; takes modifiers like M, G, etc.
max_file_uploads=<Integer>Maximum number of files that can be uploaded in a single request.
allow_url_include=<Off|On>Inclusion of PHP files from URLs. This can pose a security threat; malicious files can be included from remote servers.
extension_dir=<path>Location to find PHP extensions.
extension=<filename>Tells PHP to load the extension named. filename takes full path to the extension, else it will be sought in extension_dir.

No comments: