From DreamHost
Jump to: navigation, search
The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.
Server changes performed by DreamHost may break your modifications. You, as the user, are responsible for troubleshooting and resolving issues with your customizations.
We seriously aren't kidding about this.


Below are instructions for using your own modified version of php.ini on a domain called "".

A php.ini file is a simple text file that allows you to adjust your PHP settings. For example, the server comes with a few default settings such as a PHP memory_limit of 90MB. Other limits that are often changed are for PHP execution time and the PHP max_upload_size. This wiki walks you through how to set up a php.ini (phprc) file and add your custom adjustments.

Note2 icon.png Note: The standard term for this file is php.ini. However, as of PHP 5.3, DreamHost uses a "phprc" file instead. This acts the same way – only the name is different. In this wiki, we’ll use the term phprc.

Determine which PHP Version your website uses

Before you create a phprc file, you’ll need to know which version of PHP your site is running. The PHP version for each site is displayed in the DreamHost panel on the (Panel > ‘Domains’ > ‘Manage Domains’) page.

You’ll see the version assigned to any domain to the right under the "Web Hosting" column:
01 phpini PHP Version.fw.png
Important icon.png Important: Please be aware that DreamHost recommends you use PHP version 5.5. You can find more info about PHP here:

DreamHost pre-installs various versions of PHP on its servers. Here is the listing of PHP versions provided by DreamHost:

  • PHP 5.6 ndash; The latest version of PHP that DreamHost has to offer. Allows for settings to be customized in the same way as PHP 5.3 through 5.5.
  • PHP 5.5 ndash; A widely supported version of PHP.
  • PHP 5.4 ndash; DreamHost’s default PHP version. Also a widely supported version of PHP.
  • PHP 5.3 ndash; Officially End-Of-Lifed by as of August 14th, 2014. A widely supported version of PHP which introduces a new and easy way to customize the settings (e.g., Runtime Configuration, phprc, and so on).
  • PHP 5.2 or older versions ndash; No longer supported and installed on the shared hosting platform. VPS and Dedicated hosting accounts not utilizing an “admin user” will lose PHP 5.2 support starting February 16, 2015.

Your website may require a specific PHP version. Some PHP modules exist for 5.2 but not 5.3, such as Zend Optimizer. Some plugins or other parts of your website application may only work with a specific PHP version. You may even notice error messages or deprecated warnings on your site if the code is out of date.

Note2 icon.png Note: You should be aware of the following:
  • is no longer releasing security updates for version 5.2,
  • PHP 5.3 has been End-Of-Lifed (EOL’ed) which means the product is no longer getting security updates from the developers,,
  • PHP 5.4 will be EOL'ed this year (September 2015), and
  • PHP 5.5 is well tested, stable, and has been in production on sites around the world since June 2013.

Upgrading your site (if you're moving to Ubuntu from Debian servers)

Important icon.png Important: As a reminder, PHP 5.2 has been EOLed by and will no longer be supported by DreamHost for Shared customers as of November 3, 2014 and for VPS and Dedicated customers starting February 16, 2015 (not including admin customers)

If your site was recently moved to Ubuntu (which requires PHP 5.3), you may need to make some changes especially if you set up a custom PHP.ini file, manually edited your .htaccess file, or used a script to force PHP 5.2 on your site:

  1. Check your current PHP version in the panel as described above.
  2. If you're running an older version, upgrade to at least PHP 5.3.
  3. Log into your site via FTP.
    • You can read more in the /FTP wiki.
  4. Edit your .htaccess file.
    • Comment out any custom PHP references on your site's .htaccess files to ensure that your site loads without issue.
    • For example, add a # symbol at the beginning of any line referencing "php.ini" or "dispatch".
    The scripts look like this:
    AddHandler fastcgi-script fcg fcgi fpl
    AddHandler php-fastcgi .php
    Action php-fastcgi /cgi-bin/dispatch.fcgi
    AddHandler php-cgi .php
    Action php-cgi /cgi-bin/dispatch.cgi

If you'd like to add back any custom PHP settings, you may do so by following the steps outlined in the sections that follow.

Adding global custom changes (VPS or Dedicated ONLY)

If you have:

  • a VPS or dedicated server and want to customize php.ini for the entire server, and
  • you don't want to manage PHP yourself

Then you can add any values you'd like to customize to the following file (similar to the phprc method below) using your admin user and sudo.

  • For PHP 5.4 changes, make/edit the file:
  • For PHP 5.3 changes, make/edit the file:
  • For PHP 5.2 changes, make/edit the file:
NOTE: (8/6/13 - If you're running in mod_php mode, you should make/edit the file /etc/php5/php.ini)

Once you've made/edited that file, simply end all active PHP processes, and it should work.

Note2 icon.png Note: If you're on NGINX, you must stop NGINX before killing PHP, then restart it.

sudo /etc/init.d/nginx stop
pkill -9 php
sudo /etc/init.d/nginx start

How to add a phprc file

You can create a phprc file through an FTP client, or by logging into the server via SSH. Since creating a phprc file is simpler through an FTP client, we’ll start with those steps:

Adding a phprc file through Filezilla

  1. Create a new folder named .php in your user's home directory /home/USERNAME/.
    Note: This folder name starts with a '.' or dot, and if you're using an FTP program you may need to turn on "view hidden files and folders" to see it after you create it (for more information about that check out FTP#How do I show hidden files?.
  2. Inside that create another folder based on what version of PHP you're using (either 5.3 or 5.4).
    The shell command for 5.3 is:
    mkdir -p ~/.php/5.3
    After you run the above command the follow directories will exist: /home/username/.php/5.3/
    The shell command for 5.4 is:
    mkdir -p ~/.php/5.4
    After you run the above command the follow directories will exist: /home/username/.php/5.4/
  3. Inside all those folders, /home/USERNAME/.php/PHP_VERSION_NUM/, create a new text file named phprc.
    Note: Make sure that's the exact name, with no file extension. This phprc file is where you will put all your custom PHP settings.

phprc and php.ini

Anything set in both phprc and php.ini:

  • uses the phprc values, while
  • everything else uses the values set in php.ini.

It's an easy way to change what you want and ignore the rest.

You can also:

  • use different phprcs for each domain. But you must then assign a different user to each domain.
  • use a phprc to test out new configurations and eventually move them to php.ini.
  • edit php.ini directly.

Replacing the system php.ini entirely

To replace the system php.ini entirely:

  1. Create a file under .php/5.3/ (or .php/5.4/) named php.ini (make sure you know which version of PHP you're working with).
    Note: If this file exists, PHP will not read the system php.ini at all, so you should probably start by copying /etc/php53/php.ini or /etc/php54/php.ini as a starting point. In most cases, this file is not necessary. Please use a phprc if at all possible.

Force PHP to reload

If needed, force PHP to reload its configuration file for changes to take effect using the following shell code, or by waiting several minutes.

killall php53.cgi
killall php54.cgi

Custom php.ini for nginx servers

The following are instructions and tips to tweak your php settings or xcache settings on nginx.

Custom Global php.ini commands on Nginx

  • To completely replace DH default php config file for all your domains under a particular user, create a file .php.ini in your home:
    Note: If you compiled a custom binary, you can use .php-launcher to specify that as well, though unlikely since DH is on PHP 5 now.
  • To change what wasn't meeting your needs, we recommend you start by copying the configuration in use :
     cp /etc/php5/cgi/php.ini ~/.php-ini 

Custom php.ini commands per domain on Nginx

Since nginx runs an instance of PHP for each user, you can't specify php settings at a domain level.

However, because each user gets their own instance, you can create specific configurations for specific domains or groups of domains by migrating those sites under a different user:



  • This makes maintenance a bit more segregated, but you can still use a single user for all your cron jobs, backup operations, and so on. The new users are nothing more than "groupings" for configuration specific domains.
  • There are now two instances of PHP running instead of one, so your memory consumption increases.

Reloading Nginx

You can reload then Nginx web server to view new files (requires admin / sudo user):

sudo /etc/init.d/nginx restart

Note: If you receive a 504 timeout, then kill and restart PHP.

I modified the existing php.ini/phprc, but I'm not seeing the changes?

Here a few suggestions:

  • See the FastCGI page for instructions on how to either restart FastCGI or force a recache.
  • To restart PHP 5.2 FastCGI from the shell:
    killall -9 php5.cgi
    For PHP 5.3:
    killall -9 php53.cgi
    For PHP 5.4:
    killall -9 php54.cgi
  • If you are using PHP 5.2 with a PHP wrapper, the following may also be necessary:
    touch $HOME/

How to Customize your Settings

Now that you've got a custom php.ini (or phprc), you can make some suggested changes to customize how things run.

Note: Some variables (in particular, memory_limit, post_max_size and upload_max_filesize) are subject to internal limitations; increasing them significantly beyond the default values will not work correctly and will cause issues with your site.

Error Logging

Enabling PHP error logging is a simple step that allows easier diagnosis of problems with your website:

To enable:

  1. Add these lines to your php.ini or phprc:
     log_errors = 1
     error_log = /home/USERNAME/php.log
  2. Replace USERNAME with your server user.
  3. You may need to force PHP to reload its configuration file for changes to take effect using the following shell code, or by waiting several minutes.
    killall php53.cgi
    killall php54.cgi

Increasing the Filesize Upload Limit

The default size limit for uploading files is 7MB, which may be far too small for your needs.

To increase that limit to 64MB, use the following command:

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 500
max_input_time = 500

Increasing the PHP Memory Limit

Note2 icon.png Note: If you find you're increasing the memory a large amount, it's time to consider moving off of shared hosting, as your website has greater needs than shared hosting can reliably provide.

The default memory limit is 90M and this is usually more than sufficient for most needs.

If you wish to increase this limit, you'll want to use the following:

memory_limit = 128M

Using PHP Loaders (Zend Optimizer, IonCube Loader, and so on)

PHP Loaders are extensions to PHP to load special types of PHP files. You must modify your php.ini or phprc to activate the loader required by your special PHP files.

Below are links to pages that provide further instructions on installing and using the various PHP loaders:

Loading PHP 5.3 Extensions

The current DreamHost build of PHP 5.3 contains a number of additional extensions which are not loaded by default (for example, soap).

  1. To load, add the following line to a file at /home/username/.php/5.3/phprc:
    extension =
  2. Create the path/file for phprc if not present.
  3. Restart the server when finished.

Loading PHP 5.3 extensions on all domains (on VPS or dedicated)

On a DreamHost VPS or dedicated server, you can also create the directory /etc/php53/conf.d/. Any files in this directory are loaded by all PHP 5.3 interpreters in addition to the default file, /etc/php53/php.ini.

  1. Create a root/admin user and log in.
  2. Upload your file to your FTP server.
  3. Through shell, copy the files into the /etc/php53/conf.d/ directory:
    sudo cp filename /etc/php53/conf.d/
  4. When prompted by the machine, enter your admin user password.

Compiling PHP 5.3 extensions

To compile and load your own extensions:

  1. Download and unpack the extension (from PECL, for example).
  2. If the extension is already compiled (most binary PHP loaders are already compiled), skip to step 4.
  3. Enter the following commands:
    ./configure --with-php-config=/usr/local/php53/bin/php-config
  4. Copy the module to your .php/5.3/ directory.
  5. Assuming your user is called "username" and your module is named "", add the following to your .php/5.3/phprc:
    extension = /home/username/.php/5.3/

Your new extension is now enabled, and is loaded by all domains using PHP 5.3 under that user.

External links