Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
</Location>

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

share|improve this question

1 Answer 1

up vote 3 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
   ...
</VirtualHost>

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

 
discard

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.