Allow php scripts to work under ~username when using suPhp (custombuild)

Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » Apache Related Information
Top Level » CustomBuild » ./build php
Top Level » Apache Related Information » Php

Allow php scripts to work under ~username when using suPhp (custombuild)Last Modified: Sep 21, 2012, 2:04 am
By default, suPhp is compiled in "paranoid" mode.  This means that the settings in the user httpd.conf files:

suPHP_UserGroup username username

will require all php files to be owned by username or suPhp will throw a "500 Internal Server Error".

This does not apply to domains, when used normally, because each domain has it's own VirtualHost with the suPHP_UserGroup inside it using the correct settings.

The ~username (UserDir) method will fail in paranoid mode, because there is not a virtualhost for each ~username path, and no suPHP_UserGroup settings for each user, hence you get the 500 error.

The solution to this is to compile suPhp in "owner" mode instead of "paranoid" mode.
To do that, run these commands.

cd /usr/local/directadmin/custombuild
mkdir -p custom/suphp
cp -fp configure/suphp/configure.suphp custom/suphp/configure.suphp
perl -pi -e 's/paranoid/owner/' custom/suphp/configure.suphp
./build clean
./build suphp
cd /usr/local/directadmin/data/templates/custom
cp -f ../virtual_host* .
perl -pi -e 's/suPHP_UserGroup/#suPHP_UserGroup/' virtual_host*.conf
perl -pi -e 's/suPHP_UserGroup/#suPHP_UserGroup/' /etc/httpd/conf/httpd.conf
perl -pi -e 's/suPHP_UserGroup/#suPHP_UserGroup/' /etc/httpd/conf/extra/httpd-directories-*.conf
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

Which will change all references of suPHP_UserGroup to #suPHP_UserGroup, basically, just commenting them out.

Update: Sept 21, 2012
A new method was discovered which is much simpler than changing how suPhp works.
Until it's fully supported in DA, and if you'd like to try it (without needing the above changes), do the following:
1) Edit:


2) Add the code for each User you want this to apply to:

<Directory "/home/username">
      <IfModule mod_suphp.c>
               suPHP_Engine On
               suPHP_UserGroup username username
               SetEnv PHP_INI_SCAN_DIR /usr/local/directadmin/data/users/username/php/

and restart Apache.
Related Helpfiles
Setup a per-user php.ini to allow open_basedir with suPhp
Files uploaded with php scripts are owned by apache - how to install suPhp
I wish to customize /etc/httpd/conf/httpd.conf and not have custombuild revert it

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST