ID #1011

How do I configure different PHP settings for one subdomain or subdirectory

Applies to: Grid System

By default, your account's PHP configuration file resides at /conf/php.ini and the settings are applied globally for your account.  If you need to override the default settings for one subdomain or subdirectory, follow these steps:

  1. SSH into your account.
  2. Copy the complete file /conf/php.ini to the subdomain folder or sub-directory in which you'd like the custom settings applied.
  3. Edit the new php.ini with the custom setting(s) you want applied to the subdomain or sub-directory.
  4. Inside the same folder where you copied the php.ini, create a .htaccess file that contains the following line:
SetEnv PHPRC .

This will instruct Apache to make that environmental variable available to all scripts in that directory, and PHP will check it to determine where to find the php.ini.


Obviously, we don't want the outside world to have access to your settings in your php.ini file. The solution? Add the following lines to the  .htaccess file in the same directory with the following lines in it:

        <Files ~ "\.ini$">
        Order allow,deny
        Deny from all

This will deny any web requests to any file in that directory ending in .ini; thus preventing your PHP settings from being seen by others.

Now you have a secure php.ini file that you can modify settings in to affect the .php files within that directory.

Categories for this entry

Last update: 2011-01-15 11:49
Author: Heather Masterson
Revision: 1.6

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 3 (3 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ