This is based on a CentOS server with Apache 2.x.
You no longer need to install the module to chmod config files to 666 or upload/merge folders with 777. Because with this module enabled everything on HTTP will run with it and not through ‘apache’.
** If you are using mod_ruid instead of mod_ruid2, first of all remove the mod_ruin line from the path ‘/etc/httpd/conf/httpd.conf’
First, we will enable libcap-devel
1 |
yum -y install libcap-devel |
Once that is done we will download and install mod_ruid2.
1 2 3 4 |
wget -O mod_ruid2-0.9.8.tar.bz2 "http://downloads.sourceforge.net/project/mod-ruid/mod_ruid2/mod_ruid2-0.9.8.tar.bz2?r=&ts=1335638772&use_mirror=kent" tar xjf mod_ruid2-0.9.8.tar.bz2 cd mod_ruid2-0.9.8 apxs -a -i -l cap -c mod_ruid2.c |
Now, if you don’t get errors, mod_ruid2 should be installed and added to ‘etc/httpd/conf/httpd.conf’
Let’s make sure it was added correctly.
1 |
grep 'mod_ruid2' /etc/httpd/conf/httpd.conf |
If you get a response like this, then it has been added.
1 |
LoadModule ruid2_module /usr/lib/apache/mod_ruid2.so |
Now we need to convert the DA httpd.conf templates a bit to enable mod_ruid2 for users.
Now copy the template files to custom
1 2 3 |
cd /usr/local/directadmin/data/templates/ cp virtual_host2* custom/ chown -R diradmin:diradmin custom/ |
You have now copied the original templates to the ‘custom’ folder, so they will not be deleted
1 |
cd /usr/local/directadmin/data/templates/custom/ |
Now follow the steps for each virtual_host2 file you copied.
1 |
nano -w virtual_host2.conf |
Replace the line:
1 |
SuexecUserGroup |USER| |GROUP| |
With:
1 |
#SuexecUserGroup |USER| |GROUP| |
Add the lines below with the line you just replaced.
1 2 3 |
RMode config RUidGid |USER| |GROUP| RGroups apache |
Save the files and rewrite the HTTPd config files.
1 |
echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue |
If you want you can start rewriting the HTTPd config files manually, just paste the line below and wait for it to finish.
1 |
/usr/local/directadmin/dataskq d800 |
After the rewrite is finished you can restart HTTPd with the command below.
1 |
/etc/init.d/httpd restart |
Now mod_ruid2 should be installed and you don’t need chmod anymore, e.g. ‘chmod 666 config.php’ or ‘chmod777 uploads’.
To be sure that the webmail clients still work we need to change the owner permissions.
1 |
chown -R webapps:webapps /var/www/html |
Finally, you need to change httpd-directories.conf
1 |
nano -w /etc/httpd/conf/extra/httpd-directories.conf |
Add the RUidGid line below between and and
1 2 3 4 5 6 7 8 9 10 11 |
Options -Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all suPHP_Engine On suPHP_UserGroup webapps webapps SetEnv PHP_INI_SCAN_DIR RUidGid webapps webapps |
Q: How can I test this is working?
A: Easy, install some CMS that you are used before. Like WordPress, Joomla that required (before!!) chmod 666 or 777 to get install/working.
Q: I’ve dirs/files owned by apache for some users, must I change this?
A: Yes, you need to give the dirs/files owner of the user itself, not apache anymore. Check below
To fix the owner permissions of the dirs/files
1 2 3 4 5 6 7 |
cd /usr/local/directadmin/scripts && ./set_permissions.sh user_homes find /home/*/domains/*/public_html -type d -print0 | xargs -0 chmod 711 find /home/*/domains/*/public_html -type f -print0 | xargs -0 chmod 644 find /home/*/domains/*/public_html -type f -name '*.cgi*' -exec chmod 755 {} \; find /home/*/domains/*/public_html -type f -name '*.pl*' -exec chmod 755 {} \; find /home/*/domains/*/public_html -type f -name '*.pm*' -exec chmod 755 {} \; cd /usr/local/directadmin/data/users && for i in `ls`; do { chown -R $i:$i /home/$i/domains/*/public_html;}; done; |
* Added ‘&&’ so if they do a typo, it won’t change anything.
Finally, if you have problem with perl it should be root:root and not root:apache:
1 |
chown root:root /usr/bin/perl |
source: http://forum.directadmin.com/showthread.php?t=37467