Skip Navigation
IT Connect
Connecting You to Information Technology at the UW

 

Using a php.ini File at the UW

IT Connect > Web > Publishing > PHP > Php.ini File

This page shows you how to customize a PHP configuration file called php.ini to control some of the settings of the PHP interpreter. A php.ini file enables you to customize such settings as whether global variables are turned on, the default directory to upload files to when writing upload scripts, and the maximum allowed size for uploaded files.

Note: Care should always be taken when using custom configuration settings.

How a php.ini File is Read

When the PHP interpreter starts up, it behaves according to settings specified in any available php.ini file. The Web server will look for this file in the following locations and in the following order:

  1. The directory from which the PHP script was called
  2. The root of your Web directory (typically public_html)
  3. The Web server's default php.ini

The Web server's PHP configuration file will always be used if you don't have your own. You can find the Web server's current php.ini file in /usr/local/lib/php/php.ini-dist on vergil or ovid; this file is not available on dante or homer. Inspecting the settings in this file may be helpful if you are troubleshooting a problem with your configuration.

Creating Your Own php.ini File

A php.ini file that you write must overwrite every setting in the UW's global php.ini file to achieve full functionality (see note below). Thus you must obtain a copy of the entire recommended php.ini template(see the previous paragraph), rename it to php.ini, and then adjust the settings of the file to the values you desire. When you're done, you can put the file in your root Web directory to apply custom configuration settings to all your PHP scripts, or you can put it in a subdirectory to apply custom configuration settings to a subset of PHP scripts.

If you want to copy our default php.ini file to your web directory, you can run the following command from vergil or ovid :

cp /usr/local/lib/php/php.ini-dist ~/public_html/php.ini

Note: you cannot use your configuration file to extend the Web server's PHP settings. Only settings in your own php.ini will be used if you have one. If you set only a few settings, all other settings will use the hard-coded values in the PHP interpreter.

Overview of Select PHP Settings

Once you have downloaded the recommended php.ini template, you can search for the following variables and change their values accordingly.

Resources

For more information about php.ini files, see the following links: