From DreamHost
(Redirected from Custom PHP.ini)
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.

Dh-kb-important-icon.fw.png Important: This article contains information/examples about root/sudo/admin users.

On December 9, 2015, DreamHost disabled admin users on VPS machines (private servers). For details of why this was done, please review the following article:

If you still require sudo/admin access, you must upgrade to a Dedicated server.


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 upload size. This article walks you through how to set up a php.ini (phprc) file and add your custom adjustments.

Dh-kb-note-icon.fw.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 article, only the term phprc is used.

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 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 Domains Control Panel.fw.png
Important icon.png Important: It's highly recommended that you upgrade to the latest version of PHP as DreamHost will officially EOL PHP versions 5.3 and 5.4 on all hosting plans on January 26, 2016. Please visit the following pages to view information on how to update to the latest PHP version:

DreamHost pre-installs the following versions of PHP on its servers:

  • PHP 5.6 - 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 - A widely supported version of PHP.
  • PHP 5.4 - Soon to be End-Of-Lifed.
  • PHP 5.3 - Officially End-Of-Lifed by as of August 14th, 2014.
  • PHP 5.2 or older versions No longer supported and installed on the shared hosting platform.

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.

Dh-kb-note-icon.fw.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 and,
  • PHP 5.4 will be EOL'ed this year (September 2015),
  • PHP 5.5 is well tested, stable, and has been in production on sites around the world since June 2013.
  • PHP 5.6 is available in the panel and is the version DreamHost recommends.

How to add a phprc file

You can create a phprc file using an FTP client, or by logging into the server via SSH. Since creating a phprc file is simpler through an FTP client, these steps are covered first.

Adding a phprc file through Filezilla

  1. Log into your web server via FTP. Visit the following article for detailed instructions:
  2. Make sure you’re in your user's directory.
    You can see this in Filezilla in the ‘Remote site:’ field. It will say "/home/username".
    02 phpini Filezilla Create php folder.fw.png
  3. In the users directory, right-click your mouse and select Create directory.
    03 phpini Filezilla name php folder.fw.png
  4. Name this directory .php. Make sure you add the period at the beginning of this folder name or it will not work. If you can’t see this directory, visit the following article on how to enable hidden files:
    04 phpini Filezilla create php55 folder.fw.png
  5. Click into this new .php directory, and then create another directory.
    05 phpini Filezilla name php55 folder.fw.png
  6. Create a folder named ‘5.6’.
    The name of this directory is the version of PHP you’re using. In this example the site is running PHP 5.6.
    06 phpini Filezilla create phprc file.fw.png
  7. Click into this 5.6 folder, and then right-click and choose Create new file.
    07 phpini Filezilla name phprc file.fw.png
  8. Name the new file 'phprc'. DO NOT add a file extension, as the phprc file should never have an extension.
    08 phpini Filezilla edit phprc file.fw.png
  9. Right-click on the phprc file, and then choose View/Edit.
    A default text editor opens for you to add your customizations. These examples are very general – adjust as needed for your site.
    09 phpini Filezilla add content to phprc.fw.png
    When you try to save this file in Filezilla, the following popup box opens.
    10 phpini Filezilla save content to phprc.fw.png
  10. Check the box which says ‘Finish editing and delete local file’, and then click the Yes button to save.

The phprc file is created on your web server for any domains under this specific username using this specific version of PHP.

Adding a phprc file via SSH

  1. Log into your server via SSH. Visit the following article for instructions on how to do this based on which operating system you’re using:
  2. Make sure you’re in your users directory by typing in ‘pwd’ to confirm:
    [servername]$ pwd
    Dh-kb-note-icon.fw.png Note: In this directory, you can run a single command to create the /.php folder as well as the /5.6 folder that goes inside of it. Remember to first check which version of PHP your site is using. In the following example, we’ll assume the site is using PHP 5.6.

  3. Run the following command:
    [servername]$ mkdir -p ~/.php/5.6
  4. Change your directory into these two new folders you just created, by running the following:
    [servername]$ cd .php/5.6
    When you run pwd, you now see the entire filepath you just created:
    [servername]$ pwd
  5. In this folder, create the phprc file without an extension.
    Dh-kb-note-icon.fw.png Note: There are a few programs you can run to create this file. This example uses a program called nano.

  6. Run the following to create the phprc file.
    [servername]$ nano phprc
    A text editor pops up.
  7. In the editor, enter all the PHP customizations.
  8. When finished, press CTRL + X on your keyboard.
    You are prompted to save the file.
  9. Type in the letter y to confirm, and then click the Enter button to save.

The phprc file is created on your web server for any domains under this specific username using this specific version of PHP.

Customization options

The examples above explain how to add a phprc file with some basic contents. This section goes a little further into what you can add to this file.

Dh-kb-note-icon.fw.png 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

By default, DreamHost does not log PHP errors. However, you can enable PHP error logging through your phprc file. 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 phprc file:
     log_errors = 1
     error_log = /home/username/php.log
  2. Replace username with your SHELL user.

Increasing the filesize upload limit

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

To increase that limit to 100MB, use the following directives:

upload_max_filesize = 100M
post_max_size = 105M
max_execution_time = 500
max_input_time = 500
Dh-kb-note-icon.fw.png Note: To upload large files, post_max_size should be larger than upload_max_filesize.

Increasing the PHP memory limit

Dh-kb-note-icon.fw.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 add the following:

memory_limit = 128M

Using PHP loaders (ZendGuard Loader, IonCube Loader, and so on)

PHP Loaders are extensions to PHP which load special types of PHP files. You must modify your phprc file 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 extensions

Depending on which version of PHP you choose to use, you may notice certain extensions are not enabled by default (for example, phar).

To load an extension, add the following line your phprc file:

extension =

Compiling PHP extensions

Visit the following links for a list of available extensions:

Dh-kb-note-icon.fw.png Note: If any installation requires sudo privileges, you must upgrade to a VPS or Dedicated server.

If any installation requires you to run 'phpize', just specify the full path to your desired version of PHP. For example:

  • /usr/local/php55/bin/phpize
  • /usr/local/php56/bin/phpize

Adding global custom changes on a Dedicated server

If you have a Dedicated server it’s also possible to set a single php.ini file for the entire server, rather than set them up individually as explained above.

The following steps walk you through how to enable this.

Dh-kb-note-icon.fw.png Note: If you still have a custom phprc file setup under your user, this will override the global php.ini file for that specific user for the version of PHP for which the custom phprc file was created.

  1. Log into your server using your admin user. You can create an admin user at (Panel > ‘Dedicated’ > ‘Admin Users’).
    Dh-kb-tip-icon.fw.png Tip: Visit the SSH article for information on how to log into your server based on the operating system you’re using:

  2. Once you log into your server, navigate to the directory for the version of PHP you wish to edit:
    For PHP 5.5
    For PHP 5.6
    For PHP 7
    Once you are in that directory, you’ll see the php.ini file.
  3. Run the following command to edit it:
    sudo nano php.ini
  4. Make any adjustments and save.
  5. Kill off any PHP processes to update the file.

Once you finish, the global php.ini is now used for all sites on your server which do not have a custom phprc file enabled.

Dh-kb-note-icon.fw.png Note: If your server is running NGINX, you must stop NGINX before killing PHP, then restart it.

To stop/kill/restart NGINX:

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

Loading PHP extensions on all domains on a Dedicated server

On a DreamHost Dedicated server, you can find the directory at /etc/php56/conf.d/ (just make sure to change the php# folder to the actual version you’re updating). Any files in this directory are loaded by all PHP interpreters for this version of PHP.


All custom phprc files can be created with the instructions above for your NGINX machine. However, if you need to update your changes, run the following command under your admin user:

sudo /etc/init.d/nginx restart
Dh-kb-note-icon.fw.png Note: If you receive a 504 timeout on your website, you must stop nginx, kill PHP, and then finally restart nginx. Run the following commands under your admin user to update your settings:
sudo /etc/init.d/nginx stop
pkill -9 php
sudo /etc/init.d/nginx start


This section will help to resolve common errors you may encounter on your PHP website.

Turning off PHP errors and warnings

If you upgrade the PHP version on your site, you may suddenly see various error messages. DreamHost always recommends that you check each message, but if you’re sure they are not causing any issues with the functionality of your site then you can remove them.

To remove the error messages, add these lines to your phprc file.

display_errors = off
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

Cannot modify header information

You may notice the following error either when visiting your site or logging in to it:

Warning: Cannot modify header information - headers already sent by (output started at...'''

This is essentially an issue with how the site is coded. Most often, this simply means something was sent to the browser before the header() was called. Technically speaking, once the header block has already been sent, you cannot add

additional header lines. Most often this is caused by your code sending output to the browser before the header() function. Make sure your header() function is set in your code before any output.

If you do not want to make any adjustments to your code, you can add the following in your phprc file to resolve this.

output_buffering = 4096

If you don't see the changes made to your phprc file

It’s possible that even if you’ve correctly added the phprc file, you may not notice its customizations resolving online.

There are two suggestions to get this file updated:

  • Update your phprc file via SSH
  1. Log into your server via SSH.
  2. Once you log in, run the following command based on your version of PHP to kill off all running PHP processes:
    For PHP 5.3:
    killall -9 php53.cgi

    For PHP 5.4:

    killall -9 php54.cgi

    For PHP 5.5:

    killall -9 php55.cgi

    For PHP 5.6:

    killall -9 php56.cgi

    Killing off your PHP processes in this way updates your phprc file.

  • Update your phprc file in your panel

You can also update your phprc file by saving your domain configuration in your panel.

  1. Navigate to the (Panel > 'Domains' > 'Manage Domains') page.
  2. Click the Edit button to the right of your domain under the 'Web Hosting' column.
    The 'Manage Domains' settings page opens:
  3. In the first section, click the blue Change settings button.
    This will update your phprc file within 10 minutes.

OwnCloud errors due to OPcache

OPcache is installed on some shared servers which may cause ownCloud to throw a 500 error. If your site is running PHP 5.5 or 5.6, the following lines are added to your phprc file automatically by DreamHost:

; {{{ The following lines were automatically added by DreamHost
; }}} That's all from DreamHost 

Some users have reported errors with OwnCloud after this change. To resolve the errors, add the following line to your phprc file:

opcache.fast_shutdown = 0 

See also