Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 me@my-domain.com
    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.

share|improve this question
    
add "/etc/apache2/sites-enabled/my-domain.com" to question –  alvosu Feb 7 '11 at 10:30

2 Answers 2

Have you already checked out php-fpm with apache's mod_fastcgi? It allows you to define exactly the configuration you need through pools, and you can even chroot the users! ;)

share|improve this answer
up vote -2 down vote accepted

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 me@my-domain.com
   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.

share|improve this answer
    
You didn't answer your question. Defining php_value is not the same thing as having customized php.ini... –  Radio Dec 29 '12 at 21:58

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.