How do I configure multiple PHP.INI files on shared host running Apache?
The solution was to add a line to the vhost configuration file which set the specific PHP value I required. So rather than setting the path to php_error.log
in a custom PHP.INI file for each site I modified the vhosts config file for each site as required.
So my vhost config file now reads thus…
<VirtualHost 123.54.67.89:80>
ServerAdmin [email protected]
ServerName my-domain.com
ServerAlias www.my-domain.com
DocumentRoot /srv/www/my-domain.com/www/
ErrorLog /srv/www/my-domain.com/logs/error.log
CustomLog /srv/www/my-domain.com/logs/access.log combined
php_value error_log /srv/www/my-domain.com/logs/php_error.log
</VirtualHost>
I found the solution elsewhere on ServerFault.
Related videos on Youtube
Manoj Kumar
Updated on September 17, 2022Comments
-
Manoj Kumar almost 2 years
I would like to use a different PHP.INI file for each site hosted on a shared server.
I have modified the Apache vhosts file for each of the sites, adding the line…
PHPINIDir /srv/www/my-domain.com/
So the vhosts file
/etc/apache2/sites-enabled/my-domain.com
now reads thus…<VirtualHost 123.54.67.89:80> ServerAdmin [email protected] ServerName my-domain.com ServerAlias www.my-domain.com DocumentRoot /srv/www/my-domain.com/www/ ErrorLog /srv/www/my-domain.com/logs/error.log CustomLog /srv/www/my-domain.com/logs/access.log combined PHPINIDir /srv/www/my-domain.com/ </VirtualHost>
On reloading Apache I get the following error.
Syntax error on line 8 of /etc/apache2/sites-enabled/my-domain.com: Only first PHPINIDir directive honored per configuration tree - subsequent ones ignored ...fail!
Setting the
PHPINIDir
directive in just one of the vhosts files works, but then every site picks up that PHP.INI file.We are running PHP5.3.2 on Ubuntu 10.04.
Any suggestions on how to achieve this?
P.S. The point of this is to have each site generating its own PHP error log.
-
alvosu over 13 yearsadd "/etc/apache2/sites-enabled/my-domain.com" to question
-
-
Alex G over 11 yearsYou didn't answer your question. Defining php_value is not the same thing as having customized php.ini...