apache.htaccessphpsuphp

php.ini with suPHP in .htaccess


My server uses suPHP and so each website has it's own php.ini file. My host recommended adding the following in my .htaccess file:

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/user/public_html
</IfModule>

This basically points to the site's php.ini file. However, I am trying to have a standard .htaccess file across all sites that I don't need to edit- basically part of my "boilerplate" site that I start off with. I tried to change the above to this:

<IfModule mod_suphp.c>
suPHP_ConfigPath %{DOCUMENT_ROOT}/public_html
</IfModule>

But this doesn't work. As you can tell I am probably not understanding how this all works. Can anyone help me with the above code so that I don't need to put the exact path in for each .htaccess file, and get Apache to work out the path to my php.ini file?

I hope that makes sense, it's a little difficult to explain!


Solution

  • Just doing a sweep of old suphp Qs. mod_suphp uses the standard parameter parser so in principle %{DOCUMENT_ROOT} should work. The issue that you almost certainly have is that suPHP is generally used for shared hosting solutions and for these, the users effective DOCUMENT_ROOT is not the same as that established by the DocumentRoot directive in the system config.

    Most vendors set up an environment variable to point at the users document root. My host sets up DOCUMENT_ROOT_REAL, another that I've come across is PHP_DOCUMENT_ROOT. You need to look at your phpinfo() report to see what applies in your case. So on my .htaccess, I use

    suPHP_ConfigPath %{ENV:DOCUMENT_ROOT_REAL}/_private
    

    and that works fine for me.