Super User is a question and answer site for computer enthusiasts and power users. 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

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?


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
up vote 5 down vote accepted

When using Virtualhosts, it would look like this:

    PHPINIDir /var/www/web1

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

Also check here:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .