Support Center » Knowledgebase » How to override php.ini options

How to override php.ini options

Some php.ini options can be overridden / set on a per domain level. This may be handy to do for example, to turn off/on register_globals, or to set a site-wide include_path which can shorten and simplify your scripts.

The way to override php.ini values differ depending on the platform your site is running on.

On Unix

There are two ways to override php settings on Unix. 

  1. Inside a file called .user.ini
  2. Inside .htaccess
Method 1: .user.ini
Create a file called .user.ini in your website's root directory. The .user.ini file is formatted like php.ini in that you specify setting = value on each line. Note that you only specify things that you want to change, so don't put in the whole complete php.ini file in there. This method is similar to the Windows method mentioned below, so scroll down for more info. This is the preferred method.

Method 2: .htaccess 

Create a file called .htaccess that contains the values you want to override.

For example, to set register_globals to off insert the following line:

php_flag register_globals off

To increase your memory_limit - first find out what your current memory_limit is using a phpinfo() page. Choose a reasonable limit. Setting this to a value too absurdly high will negatively impact the stability of your site and make it more vulnerable to denial of service attacks. Note that our default memory limit should be 128M. If you find that your memory limit is less than 128M please contact us to update this on your server.

php_value memory_limit 128M

To increase max_execution_time - note that the unit is second. Do not add any prefixes such as s or m or anything to the end of the number:

php_value max_execution_time 300

Then upload the .htaccess file into your website's root directory.

For a list of settings that can be overridden through the .htaccess file, follow this link:

Note that you can only override the settings marked as php_ini_all.

On Windows

You can customise certain php settings by entering the settings in a file called .user.ini The format of this file is similar to php.ini file. You would only enter what you want to override in here. Not all settings can be overridden.

For example, to increase the memory_limit settings, enter this line in the .user.ini file:
memory_limit = 256M

Article Details
Article ID: 120
Created On: 09 Nov 2006 11:22 AM
 Login [Lost Password] 
Remember Me:
Please note that the login and password to the support area is NOT the same as your hosting control panel login and password
 Article Options
Home | Register | Submit a Ticket | Knowledgebase | Downloads | Control Panel User's Guide | Server Status