2.5. Configuring PHP

PHP uses settings in a file named php.ini to control some of its behavior. PHP looks for php.ini when it begins and uses the settings that it finds. If PHP can't find the file, it uses a set of default settings. The default location for the php.ini file is one of the following unless you change it during installation:

  • Windows: The system directory, depending on the Windows version: on Windows 98/Me/XP, windows; on Windows NT/2000 (and sometimes XP), winnt

  • Unix, Linux, and Mac: /usr/local/lib

If the php.ini file isn't installed during installation, you need to install it now. A configuration file with default settings, called php.ini-dist, is included in the PHP distribution. Copy this file into the appropriate location, such as the default locations just mentioned, changing its name to php.ini.

If you have a previous version of PHP installed (such as PHP 4.3), make a backup copy of the php.ini file before you overwrite it with the php.ini file for PHP 5 or 6. You can then see the settings you are currently using and change the settings in the new php.ini file to match the current settings.

To configure PHP, follow these steps:

  1. Open the php.ini file for editing.

  2. Change the settings you want to change.

    Steps 3, 4, and 5 mention some specific settings that you should always change if you're using the specified environment.

  3. Only if you're using PHP 5 or earlier, turn ...

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.