I have a LAMP server serving a number of different websites using NameVirtualHosts.
Until recently having a global php.ini file has been just fine, but recently one of our developers has requested some settings in php.ini that I'd rather not set globally.
I'm pretty sure I've heard that you can set up php.ini files on a per-site basis, but don't know how to go about doing this.
Can somebody point me in the right direction as to how to accomplish this?
Most settings that you would place in your php.ini can also be placed in a .htaccess or in the apache configuration for that site. For example one of my virtual hosts has this in the .htaccess
You can also specify configuration settings in the Apache configuration file (httpd.conf/apache.conf). In your case you can specify the configuration values within the context.
The following example should set upload_max_filesize to 10M for the virtual host example.com.
If you do not want to set this value for the whole of the site, but to one particular directory where the application lives, then you can specify the values within a .
See http://php.net/manual/en/configuration.changes.php for more explanation.
Another suggestion is to use mod-fastcgi or mod-fcgi, which run PHP as a separate standalone daemon. Then, for each website, you can define a separate user and php.ini config file.
Yet another option is suPHP which allows you to define a php.ini for each VirtualHost. It also allows you to specify a PHP version for each VirtualHost.