How can I run a custom php.ini for each domain if I have plesk?

Often times you'll need to change a few settings in PHP for one domain on your server, but not another. An example would be if you need to enable open_basedir for one of the domains that you host on your dedicated server, while not affecting the other domains. This can safely be done by using vhost.conf. The vhost.conf file is usually found at:

 
/var/www/vhosts/yourdomain.com/conf/vhost.conf

What should I put in my vhost.conf file?

The vhost.conf file is very similar to the php.ini config file, with a few small differences. Below is a very simple example of what a vhost.conf file might look like
    <Directory /var/www/vhosts/yourdomain.com/httpdocs>
    php_admin_flag safe_mode off
    php_admin_value open_basedir none
    </Directory>

Notice that the first line of the file should point to the directory of your websites content. The last line of the file will always contain"</Directory>", declaring the end of file.
At this point you can start adding settings to your new vhost.conf file. This is where a good working knowledge of the php.ini file comes in handy.

The content of the vhost.conf file is similar but different than that of the php.ini file. As you can see in the above example, we've disabled safe_mode and open_basedir. You may have noticed the major difference between vhost.conf and php.ini already. As you can see we've added 'php_admin_flag' and 'php_admin_value' in front of the actual setting. Also, in vhost.conf there is no '=' between the setting and the value.

php_admin_flag - You will pre-pend your desired setting with this string if the setting you are changing is a boolean expression. Meaning, if its on or off, true or false.

php_admin_value - This is used if the value is not simply 'on' or 'off'.

You can now add any setting from php.ini into the vhost.conf.


How to make the changes effective?

Once you have made the changes in the vhost.conf file you will need to make the effective for the domain, to do this you must execute "/usr/local/psa/admin/bin/websrvmng -a -v" from the SSH shell but with out the quote marks.



Related Articles

No related articles were found.

Attachments

No attachments were found.

Visitor Comments

No visitor comments posted. Post a comment

Post Comment for "How can I run a custom php.ini for each domain if I have plesk?"

To post a comment for this article, simply complete the form below. Fields marked with an asterisk are required.

   Name:
   Email:
* Comment:
* Enter the code below:

 

Article Details

Last Updated
27th of February, 2010

See also:
Troubleshooting problems with your site.

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF


User Opinions

100% thumbs up 0% thumbs down (1 vote)

How would you rate this answer?




Thank you for rating this answer.

Continue