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.

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
</VirtualHost>

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

1 Answer 1

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/"
</VirtualHost>

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

 
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.