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

install mod_ruid2

cd /tmp
apt-get update
aptitude install libcap2-dev bzip2
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/

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)
<IfModule !mod_ruid2.c>
SuexecUserGroup |USER| |GROUP|
<IfModule mod_ruid2.c>
RMode config
RGroups apache
                php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f |USER|@|DOMAIN|'

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
<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
   RUidGid webapps webapps

restart httpd & test mod_ruid

/etc/init.d/httpd restart

vim /var/www/html/ruid.php
 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 && ./ 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;


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