Hello all, I was wondering if anyone had a script that they run to reset ownership on files and directories for users who use joomla or other php components that upload files and then set the owner to apache.
I understand that there are ways around this (fcgi, suphp) but since Parallels is going to be adding fcgi as a native component in the next version, those work arounds are not ideal since they will be soon obsolete.
This is rough and isnt very elegant, and Im not sure if this will even work as desired or if there is a better way.
Please feel free to post something better or make any changes you think are necessary.
The idea is to only change the files and folders where apache is the owner, so that way nothing else is messed up.
I understand that there are ways around this (fcgi, suphp) but since Parallels is going to be adding fcgi as a native component in the next version, those work arounds are not ideal since they will be soon obsolete.
This is rough and isnt very elegant, and Im not sure if this will even work as desired or if there is a better way.
Please feel free to post something better or make any changes you think are necessary.
The idea is to only change the files and folders where apache is the owner, so that way nothing else is messed up.
Code:
find /var/www/vhosts -user apache | grep '/httpdocs/' > /tmp/tmp-list
for i in `cat /tmp/tmp-list`; do
DOMAIN=`echo $i | awk -F/ '{print $5}'` > /dev/null 2>&1
echo Procesing $DOMAIN
USER=`ls -la /var/www/vhosts/$DOMAIN/httpdocs/index.* | awk '{print $3}'` > /dev/null 2>&1
GROUP=`ls -la /var/www/vhosts/$DOMAIN/httpdocs/index.* | awk '{print $4}'` > /dev/null 2>&1
if [ `grep -c $DOMAIN /tmp/tmp-list` -gt 0 ]; then
chown -R $USER:$GROUP `grep $DOMAIN /tmp/tmp-list`
fi
for $subdomain in `ls /var/www/vhosts/$DOMAIN/subdomains`; do
echo Procesing subdomain $subdomain
USER=`ls -la /var/www/vhosts/$DOMAIN/subdomains/$subdomain/httpdocs | awk '{print $3}'` > /dev/null 2>&1
GROUP=`ls -la /var/www/vhosts/$DOMAIN/subdomains/$subdomain/httpdocs | awk '{print $4}'` > /dev/null 2>&1
if [ `grep -c $subdomain /tmp/tmp-list` -gt 0 ]; then
chown -R $USER:$GROUP `grep $subdomain /tmp/tmp-list`
fi
done
done
Last edited: