PHP Developers Network
http://forums.devnetwork.net/

php permissions
http://forums.devnetwork.net/viewtopic.php?f=30&t=131776
Page 1 of 1

Author:  cnapsys [ Fri Sep 23, 2011 2:20 pm ]
Post subject:  php permissions

Hey all,
I may have posted this in the wrong section at first...

I'm having a bit of a problem trying to set up a custom php script.
Here's what's going on:
I have an upload script that allows registered users to upload files to a temp /upload/ directory.
Upon review from admins the files need to be copied to another folder.
At first I had a problem with open_basedir restrictions but after fixing that with a vhost.conf file I was able to bypass that.
My real issue now is not so much about php itself but rather related to linux permissions.
I get a permission denied when trying to copy the files and it's my understanding that apache/php does not have permission to write to the destination folder.
In theory I think I know what needs to be done I just don't have the skills to pull this off, so any help is welcomed.

Here's what I'm thinking.
PHP needs write permission to the destination folder.

I've tried the following.
Switched php from running as an apache module to fastcgi...
The /destination/ folder is owned by user: 'domainadmin' (created by plesk when the domain is set up initially) and group: 'psacln'
the php script is owned by the same: domainadmin | psacln
when loading the script i get --> Permission denied

I chmodded the /dest/ folder to 777 and tried it again.

The file gets copied fine now but it is owned by apache | apache

Shouldn't fastcgi make all php scripts run as the 'domainadmin' ??? and not needing any higher perm than 755??

Lastly I need the domain admin account to be able to see those copied files via FTP.
Please be as detailed as possible. I'm a big noob but willing to learn fast

Setup is dedicated box running RHEL + Plesk

I've been trying to make this work for over a week now. I'm tired, confused and can't figure out what needs to be done.
Any help is greatly appreciated.

c

Author:  Christopher [ Fri Sep 23, 2011 3:00 pm ]
Post subject:  Re: php permissions

The uploaded files should be owned by the web server because PHP runs within it as a module. You can set the permissions when you upload the file to something more permissive, or put the domainadmin account in the apache group so you only need group permissions.

Author:  cnapsys [ Fri Sep 23, 2011 4:46 pm ]
Post subject:  Re: php permissions

Hey chris,
thanks for taking the time to post.
I'm still a bit confused though.
Isn't the whole idea of running php as fascgi to make php scripts run as the domainadmin and not as an apache module?
Or are you just saying I should drop that idea and continue to use it as an apache module and add the domain admin to the apache group?
Are there any security issues in doing that?
And will this work with 755 permissions?
Sorry to ask such noobish questions I just want to make sure I get it right...

c

Author:  Doug G [ Sat Sep 24, 2011 8:16 pm ]
Post subject:  Re: php permissions

Look into suexec maybe.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/