Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to use a different php.ini file foreach VirtualHost in apache?

I know that there are the php_admin_values

<Location /stat/>
    php_admin_value safe_mode off

But i want to specify a full php.ini file for a virtualhost.

share|improve this question
up vote 4 down vote accepted

You will need to use something like suPHP to achieve this. In addition to running each VirtualHost's php execution as a different user - it allows you to have multiple php.ini files for VirtualHosts and Directories (Based on .htaccess suPHP_Config flag)

You can install suPHP via aptitude: sudo apt-get install suphp-common libapache2-mod-suphp One of the main differences is you can now setup php to be executed as a user - rather than having all php scripts executable by the www-data user - this alone provides a lot of convenience and security when hosting multiple users on one server as it cuts down the needs for 777 and 666 permissions (In fact you should never need to use 777 or 666 ever again - 755/644 should always be sufficient)

An example virtual host:

<VirtualHost *:80>
   DocumentRoot /home/marco/www/
   suPHP_UserGroup marco marco
   suPHP_Config /home/marco/etc/php.ini

You can also set the suPHP_Config directive in .htaccess files - provided you have AllowOverride setup properly.

share|improve this answer
+1 Didn't know about this one :) – AntonioCS Sep 14 '10 at 11:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.