LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-15-2010, 10:47 PM   #1
bahbahthelamb
Member
 
Registered: Jul 2006
Location: Fort Worth, Texas
Distribution: openSUSE 11, RHEL4 & 5, CentOS 5
Posts: 57

Rep: Reputation: 16
Recursively fixing FTP ownership on a Plesk managed web server


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.

Last edited by bahbahthelamb; 03-15-2010 at 10:55 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
In plesk , I wish to have a backup cron job, ftp back up file to another ftp server? muskiediver Linux - General 6 07-16-2009 03:13 AM
Solution to have svn managed file-permissions and ownership nobody25145147 Linux - Software 0 01-25-2009 07:36 AM
Moving a Fedora 7 Web Server that uses plesk and hosts DNS oldcarguy85 Linux - Server 1 04-20-2008 07:56 AM
3 issues: Making swap, fixing partitions, changing ownership of mounted filesystem. Dunedain Linux - Newbie 2 01-27-2004 03:52 PM
need help fixing web server joesbox Linux - General 2 11-11-2003 09:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration