Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of the clients requested a personal php.ini configuration for his website, so I have set his VirtualHost as follows:

<VirtualHost *:80>
    DocumentRoot "/home/alex/www.domain.tld"
    ServerName www.domain.tld
    AssignUserID alex alex
    PHPINIDir /home/alex/php.ini

The client created php.ini file under /home/alex/ which contains only this setting:

session.save_path = "/home/alex/.php_sessions/"

Afterall he started to complaint that he sees all other session files generated by other clients' websites.

After doing some basic troubleshooting, I realized, that his php.ini settings are affecting all websites specified in the httpd-vhosts.conf.

Question is why? Since PHPINIDir is only specified inside one specific VirtualHost?

share|improve this question
You aren't supposed to include the actual filename, just the path /home/alex I think. – Kevin Wheeler Dec 1 '15 at 18:19
up vote 2 down vote accepted

Individual virtualhosts cannot have their own PHPINIDir because the php.ini file is read when apache+mod_php starts up, before it even begins handling requests. For whatever reason, instead of giving a warning with this usage this directive will set the global INI directory and continue on its merry way.

Instead, you must use the php_value, php_flag, php_admin_value and php_admin_flag Apache directives to override the specific settings you want for this virtual host. (See here) In this case, you would do:

<VirtualHost *:80>
    DocumentRoot "/home/alex/www.domain.tld"
    ServerName www.domain.tld
    AssignUserID alex alex
    php_value session.save_path "/home/alex/.php_sessions/"

In this case, it would load the default php.ini file, then change session.save_path to the given directory, just for this virtualhost.

share|improve this answer
I cannot let users edit httpd-vhosts.conf, in this case i need to program some front-end interface, which is not an easy option... – Radio Dec 29 '12 at 22:18
@Radio The php_value and php_flag settings can be used in .htaccess if AllowOverride Options is set. – DerfK Dec 30 '12 at 16:59

Your Answer


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.