Something about php.ini

Aug 27, 2007 15:17 GMT  ·  By

php.ini is the configuration file for php and is read when php is started. php.ini is searched for in these locations in this order:

- SAPI module specific location - The PHPRC environment variable. If you are using PHPRC environment variable, you will have to specify the directory that contains php.ini and not the direct path to php.ini: export PHPRC=/your/path , not export PHPRC=/your/path/php.ini. - As of PHP 5.2.0, the following registry locations are searched for in the following order: HKEY_LOCAL_MACHINE/SOFTWARE/PHP/x.y.z/IniFilePath, HKEY_LOCAL_MACHINE/SOFTWARE/PHP/x.y/IniFilePath and HKEY_LOCAL_MACHINE/SOFTWARE/PHP/x/IniFilePath, where x, y and z stand for the PHP major, minor and release versions. HKEY_LOCAL_MACHINE/SOFTWARE/PHP/IniFilePath (Windows Registry location) - Current working directory (except CLI) - The web server's directory (for SAPI modules) - The directory of PHP (otherwise in Windows) - Windows directory (C:/windows or C:/winnt) (for Windows), or --with-config-file-path compile time option. The path can be overwritten using -c argument in command prompt. For Windows, the compile directory is the windows folder: c:/windows.

The most important parameters from php.ini or the parameters that are mostly changed are: safe_mode, register_globals, upload_max_filesize, post_max_size and max_execution_time.

safe_mode is an attempt to solve the shared-server security problem. safe-mode will be removed in version 6.0

register_globals - on the earlier versions of PHP, register_globals was set for easier, but less secure coding. Now it is recommended to turn it off.

upload_max_filesize - the default value is 2MB. If you don`t want to have problems later, set it to 8MB.

post_max_size sets max size of post data allowed. This setting also affects file upload.

max_execution_time sets the maximum time in seconds; a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30.

More info about php.ini in the next article.