Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I make it so that each user (with Apache's mod_userdir) has a php.ini file in their home directory that gets used along w/ the system php.ini (currently in /etc/php5/php.ini?

Cheers!

EDIT: This requires PHP 5.2.x, basically this server can't run PHP 5.3 because of legacy code.

EDIT: Most solutions with .htaccess and php_value won't work here because we use FastCGI with SuExec

share|improve this question

2 Answers 2

up vote 5 down vote accepted
+25

When using Virtualhosts, it would look like this:

<VirtualHost 1.2.3.4:80>
    [...]
    PHPINIDir /var/www/web1
    [...]
</VirtualHost>

Where php.ini would be located in /var/www/web1/php.ini.

Also check here: http://www.howtoforge.com/how-to-specify-a-custom-php.ini-for-a-website-apache2-with-mod_php

share|improve this answer
    
Would this use the system php.ini AND the custom override? –  Kristopher Ives Jun 23 '10 at 22:26
    
@kristopher - Yes it would, any value not found in the custom one would be fetched from the system php.ini –  BloodPhilia Jun 24 '10 at 8:02

With PHP 5.3.0, check out the .user.ini files. I haven't tried this, but it sounds like what you want:

In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). Only INI settings with the modes PHP_INI_PERDIR and PHP_INI_USER will be recognized in .user.ini-style INI files.

Or else, create a .htaccess file for each user. Inside .htaccess, modify the include_path:

php_value include_path "./php:/php/includes"

share|improve this answer
    
Sorry, we can't use php_value inside our .htaccess :( –  Kristopher Ives Jun 23 '10 at 23:07

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.