php permissions

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
Forum Newbie
Posts: 15
Joined: Tue Nov 14, 2006 5:57 pm

php permissions

Post by cnapsys »

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.

User avatar
Site Administrator
Posts: 13595
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: php permissions

Post by Christopher »

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.
Forum Newbie
Posts: 15
Joined: Tue Nov 14, 2006 5:57 pm

Re: php permissions

Post by cnapsys »

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...

Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: php permissions

Post by Doug G »

Look into suexec maybe.
Post Reply