flash gordon Posted October 21, 2008 Share Posted October 21, 2008 Hello. First off, please forgive my ignorance with this subject matter. Server side and php is not my thing. Ok...end disclaimer. Here is my situation. I have a dedicated server. The server has a user called "fudcake." Fudcake owns several other domains/users on the server such "foo", "bar", and "muckhead." I want fudcake to be able to copy or move files from it's domain of myserver.com/~fudcake to myserver.com/~foo. Now remember fudcake owns foo. Is this even possible? If so, what should be the server set up: suPHP, safe mode, chmods, etc? Thanks for your time. Cheers Quote Link to comment Share on other sites More sharing options...
neogranas Posted October 21, 2008 Share Posted October 21, 2008 Is it just a one time thing, or do you want it to continually keep the files between both domains the same? If it's just once, do a cp -r of the directory that the first domain's files are in to the second's directory. If you need it to continually keep the same content, don't waste space on your hard drive and just symlink the directories. ln -s /path/to/dir1/ /path/to/dir2/ Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 I want fudcake to be able to copy or move files from it's domain of myserver.com/~fudcake to myserver.com/~foo Sorry, they are the same domain? Is that a typo or what? Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 Oops. Didn't really read the question properly. If this is all on the same server there isn't anything special to consider. Just move the files. Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 yea, I didn't think it would be a big thing either. However, I can't do it for the life of me. I'm trying to do it file_put_contents() but I get a permission denied error. I think the problem is php is running under the user "nobody" and "nobody" has no permission. That's just a guess. What else do you think is going on? Can i give you any error messages? as for myserver.com/~fudcake and myserver.com/~foo this is the way the server represents accounts on the same machine. fudcake.com and foo.com is the same thing. Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 Any reason your trying to use php to do this? Id login and simply move the files... cp -R /home/fudcake/* /home/foo/ Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 oh yea....i got a flash application that allows user uploads from the "main" folder of "fudcake". From there based upon the user's login id, I move the file with php to their own folder. So it's going to be a continuous process of moving files. Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 Ok then, can we see some code? And any error messgaes? Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 <?php echo "Getting sound1.sql<pre>"; echo exec("whoami"); print_r(file_get_contents("/home/philkc34/public_html/config.xml")); print_r(file_put_contents("/home/philkc34/public_html/stuff.txt","success")); echo "</pre>"; ?> any ideas? error message: Getting sound1.sql reseller Warning: file_get_contents(/home/philkc34/public_html/config.xml) [function.file-get-contents]: failed to open stream: Permission denied in /home/reseller/public_html/test.php on line 4 Warning: file_put_contents(/home/philkc34/public_html/stuff.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/reseller/public_html/test.php on line 5 Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 any ideas? Yep. You don't (or better still php doesn't) have permissions to write to or read from said directories. They will need be writable/readable by the apache process. Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 ok....can you give some guidance on how to make that possible? Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 $ chmod o+wrx /home/philkc34/public_html Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 the current permissions are already "750." Isn't that the same? Would I run that command from putty? Quote Link to comment Share on other sites More sharing options...
trq Posted October 21, 2008 Share Posted October 21, 2008 That meens apache is locked out completely. No read/write or execute. Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 wow...that worked! I spent months and months on that. I owe you my first born. haha Ok....I suppose the follow up question. cPanel is actually creating the folder. I don't want to have to manually configure the permissions all the time. So do you know how to set this up so that so that the user account is created with the correct permissions and "apache permissions"? Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 21, 2008 Author Share Posted October 21, 2008 ....actually 1 error still exist. I still don't have write access..... Warning: file_put_contents(/home/philkc34/public_html/stuff.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/reseller/public_html/test.php on line 5 Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 23, 2008 Author Share Posted October 23, 2008 Okay...well it looks like I got everything solved on that end. However, I have to do this process for every client domain on the server. Is there away to declare apache as part of the group/owner on a more global level? Thanks again for all the help. Quote Link to comment Share on other sites More sharing options...
trq Posted October 23, 2008 Share Posted October 23, 2008 Is there away to declare apache as part of the group/owner on a more global level? I think your asking how to change permissions on multiple directories at once? This really has nothing to do with php. Anyways, providing all these domains are within home setup just like your first example. $ chmod o+wrx /home/*/public_html Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 23, 2008 Author Share Posted October 23, 2008 thanks for the answer, thorpe. But that only works for directories that are already created. I need that to be the default permission for future accounts as well. Know what i mean? Quote Link to comment Share on other sites More sharing options...
trq Posted October 23, 2008 Share Posted October 23, 2008 Short of making your /home directory world readable / writtable (bad idea) you'll need to change permissions on each directory as it is created. How exactly are these domains created? Is it all scripted? Quote Link to comment Share on other sites More sharing options...
trq Posted October 23, 2008 Share Posted October 23, 2008 Actually this entire setup is very insecure. Theres nothing stopping any user from being able to write to or read from any other usrs /home/*/public_html directory. Quote Link to comment Share on other sites More sharing options...
flash gordon Posted October 23, 2008 Author Share Posted October 23, 2008 ok, point taken. We'll talk about about the best way. Maybe you or I can post one final note in this thread with the solution we come up with to benefit the community. Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.