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.
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 thewww-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:
You can also set the suPHP_Config directive in
.htaccess
files - provided you haveAllowOverride
setup properly.