Creating a directory problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Creating a directory problem

Post by mjseaden »

Dear All

I'm getting this error when using "mkdir(<dirname>, 0770)" on my Linux Apache server:

Code: Select all

Warning: stat failed for <root path>/upload/50cd23f1ec7bed66799da314534f8992 (errno=13 - Permission denied) in <root path>/admin on line 2356 Warning: MkDir failed (Permission denied) in <root path>/admin on line 2356 Warning: Unable to create
I've tried to set the upload directory to public read/write, and it seems to stick to that. Is there a common cause for this problem (which is probably the most likely situation?)

Many thanks

Mark
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Remember that all PHP scripts run as "nobody" on Unix servers (i.e. as good as "anonymous - the lowliest of low") - so approach the permission denied error from this perspective to get around it, not from YOUR perspective.
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

launchcode, can you clarify what you mean?
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

I mean that your PHP script runs as "nobody" - this is a default user account which has virtually no user/group rights to do anything on the server - least of all set a chmod of 770 which is trying to set full rwx for users/groups (of which it isn't a member).
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

So how do I get around this? I set the directory to public read/write, what else do I need to do?

Cheers

Mark
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

You cannot get around it - user "nobody" will never have the right permission levels to perform a chmod 770 command.

Unless you happen to be able to run the CGI version of PHP? (rather than the Apache module)
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

So how do I create a directory on my server using Apache? Or upload files?

Cheers

Mark
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

How do I setup my server so that I can use the 'mkdir' command to make a directory on my server?

Many thanks

Mark
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Is anyone out there?

Cheers

Mark
User avatar
xisle
Forum Contributor
Posts: 249
Joined: Wed Jun 25, 2003 1:53 pm

Post by xisle »

User 'nobody' will not have the appropriate permissions, as launchcode
has said. You will have to create upload directories under an account
with appropriate permissions, like your account.
Set the dir to 0777 so 'nobody' can upload.
Depending on the purpose of
the script you can also run command line version of the script under your account manually or with crontab.
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Hi Xilse,

Thanks for the help - I've solved it now. I've also set the Public attributes to 'execute' (giving an 0706 CHMOD). This has now worked, otherwise I wouldn't have been able to access the upload directory.

Cheers
Mark
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

706 isn't execute, what you've done is allow the "world" to read/write to that folder.

705 is execute (but will not work in this instance).
Post Reply