mod_ruid จัดการให้ php-cli ไม่ต้องมา chmod 777 เองให้วุ่นวายเหมือนใช้โฮส cPanel

install mod_ruid2

cd /tmp
apt-get update
aptitude install libcap2-dev bzip2
wget http://heanet.dl.sourceforge.net/project/mod-ruid/mod_ruid2/mod_ruid2-0.9.8.tar.bz2
tar xjf mod_ruid2-0.9.8.tar.bz2
cd mod_ruid2-0.9.8
apxs -a -i -l cap -c mod_ruid2.c

.
check module

grep mod_ruid2 /etc/httpd/conf/httpd.conf

#it show
LoadModule ruid2_module       /usr/lib/apache/mod_ruid2.so

.
edit custom template for directadmin oldversion

cd /usr/local/directadmin/data/templates/
cp virtual_host2* custom/
chown -R diradmin:diradmin custom/
cd custom/

#edit custom template for oldversion directadmin
vim virtual_host2.conf (& virtual_host2_secure.conf virtual_host2_secure_sub.conf virtual_host2_sub.conf)
#example
<IfModule !mod_ruid2.c>
SuexecUserGroup |USER| |GROUP|
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid |USER| |GROUP|
RGroups apache
</IfModule>
                php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|'
|*endif|

.
run & edit

echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq d800
chown -R webapps:webapps /var/www/html

vim /etc/httpd/conf/httpd.conf #or /etc/httpd/conf/extra/httpd-directories.conf
#example
<Directory "/var/www/html">
    Options -Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
   <IfModule mod_suphp.c>
        suPHP_Engine On
        suPHP_UserGroup webapps webapps
        SetEnv PHP_INI_SCAN_DIR
   </IfModule>
   RUidGid webapps webapps
</Directory>

.
restart httpd & test mod_ruid

/etc/init.d/httpd restart

vim /var/www/html/ruid.php
<?php
 mkdir('modruid2');
 file_put_contents('modruid2/test.txt', 'Hello World');
?>
#run ruid.php & check file bypass permission with mod_ruid2 in /var/www/html/

.
reset permission all

cd /usr/local/directadmin/scripts && ./set_permissions.sh user_homes
find /home/*/domains/*/public_html -type d -print0 | xargs -0 chmod 755
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;

.
ref: http://www.thaihosttalk.com/showthread.php/71638
ref: http://forum.directadmin.com/showthread.php?t=37467
ref: http://directadminguru.com/how-to-upgrade-your-directadmin-server-with-mod_ruid2/

share: How to Install mod_ruid2 on Debian 64bit DirectAdmin installed