Here is a script that I borrowed from various sources and added some of my own items to theoretically “fix” permissions in the /home directory for all users. It’s especially useful after uploading a bunch of websites via sftp logged in as root (after you created their accounts of course!). USE AT YOUR OWN RISK - no warranties! FYI I saved mine to $HESTIA/bin/m-fixperms (I use m- for my custom scripts.) Also I don’t use DNS in Hestia so that was not accounted for. And finally this script supresses any errors. You can add them back in by removing the “&>/dev/null” portions.
cd /home/
for i in `ls | grep -v 'lost+found'`; do
if id "$i" &>/dev/null ; then
chattr -i /home/*/conf &>/dev/null
chown -R ${i}:${i} /home/$i &>/dev/null
chown root:root /home/$i/conf &>/dev/null
chown root:root /home/$i/conf/* &>/dev/null
chown Debian-exim:mail /home/$i/conf/mail/* &>/dev/null
chown dovecot:mail /home/$i/conf/mail/*/passwd &>/dev/null
chown $i:$i /home/$i/conf/web &>/dev/null
chown $i:$i /home/$i/conf/web/* &>/dev/null
chown $i:www-data /home/$i/web/*/public_* &>/dev/null
chmod -R u=rw /home/$i/web/*/public_html/* &>/dev/null
chmod -R go=r /home/$i/web/*/public_html/* &>/dev/null
chattr +i /home/$i/conf &>/dev/null
echo $i done
fi
done
That didn’t help. So why am I now getting error 500 on all sites? I had a clean install a week ago, copied in web files and restored databases and everything was working.
So interestingly enough, I keep refreshing one website and rerun v-rebuild-users. While its running, I get an nginx error page and then before it finishes it’s back to error 500.
I am 1.2.3.
How the hell would v-rebuild hose the nginx config?!?
I agree - so why are my sites down? I can’t identify the issue and I’m kind of hanging this on your head. “oh just run this command - I don’t know everything it does but it should work fine”.
v-rebuild-users resets the configs and might also fix the ‘home directory permissions’ to the defaults (this was your thread title).
this runs everytime during an upgrade, to make sure global changes are compatible with the default config and default templates.
that is also the reason why you should not change anything in the default templates, as all these changes get overridden.
that v-script does not change the permission on files inside your public_html folder (and that’s not what your topics said anyway)
if your system is borked after running this command you have a bigger problem, because you did something before that is not compatible with how Hestia works.
running chmod recursively already messed up your permissions within the public_html folder and therefore broke your system. chmod -R is bad practise because it simply does not distinguish between folders and files which eventually need different permission sets. especially folder need executable rights which translate into ‘being able to change into that folder’.
sorry to say, but your script is very much not advisable to use.
PS: this again is the wrong approach, as it will make your files executable as well, which they should not be, as this increases the risk to run arbitrary shell code more easily and so on: