I made the mistake of running chown -R 775 /var/www/vhosts instead of chmod -R 775 /var/www/vhosts and in a short blink, all the sites started throwing HTTP 403s. So I wrote this php-based shell script to fix the issue. I figured that I would post it here in case someone else needs it:
Code:
#!/usr/bin/php
<?php
$sites = explode ("\n", trim (shell_exec ("ls /var/www/vhosts")));
mysql_connect ("localhost", "admin", shell_exec ("cat /etc/psa/.psa.shadow"));
mysql_select_db ("psa");
foreach ($sites as $site) {
$r = mysql_query ("select s.login from sys_users s where s.home='/var/www/vhosts/".$site."';");
if ($result = mysql_fetch_array ($r)) {
shell_exec ("chown -R ".$result[0]." /var/www/vhosts/".$site);
print "Owner of /var/www/vhosts/".$site." has been updated to ".$result[0]."\n";
}
}
mysql_close ();
?>
I'm sure there is even a simpler method, but this method at least works.