A2 Hosting Forums

Full Version: Permissions for php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

Having a little permissions problem with a php script.  I have a php script that is getting "permission denied" errors when trying to write, move, or rename files.  Originally I had password-protected the directory I'm using, figured that was the problem, and removed the password protection, but the error persists.  

I'm guessing the default is blocking php scripts from creating or changing files.  Is there a way to change this so the script will run properly?

Thanks!

mwreed Wrote:
Hi there,

Having a little permissions problem with a php script.  I have a php script that is getting "permission denied" errors when trying to write, move, or rename files.  Originally I had password-protected the directory I'm using, figured that was the problem, and removed the password protection, but the error persists.  

I'm guessing the default is blocking php scripts from creating or changing files.  Is there a way to change this so the script will run properly?

Thanks!


I'm guessing this is a web script and not CLI based on your problem.  That being that your directory and file are owned by you and the web server runs as the user "nobody".  To fix this you need to change the permission on the directory to 777 and the file to 666.  So...

$ chmod 777 <dir_name>
$ chmod 666 <dir_name>/<filename>

You should also be aware that if you are a shared hosting package anyone else on your server will also have access to this file via their web server, if they know the path/dir/filename information.  Thus this poses a certain amount of a security risk.

Regards,

-klp

Reference URL's