June 8, 2010

PHP and Permissions

Question by Moe

I recently moved my website to a new host and now am experiencing some broken code..

I have an uploading script that is now returning this:

move_uploaded_file() failed to open
stream: Permission denied in *..

I’ve set the upload directory to 777 which worked fine, but my script is needed to have top level permissions..

(As the script itself sets permission to directories, does lots of copying etc)

Is there a way in apache I can set the PHP script to the owner of all the folders on my server?

Thanks

Also
When looking in phpInfo()

Under
apache2handler

User/Group  nobody(99)/99 

Is this related?

Answer by Starx

well,
When you are trying to set the permission like “0777”, you must be running on same authority.

What I mean is.
For example, your script tells to change a folder/file permission to 0777, but the folder or file already has a permission and that is ‘0755’ so you are not authorised to make that change. as the user have only 5 authority.

Either, you need to login to FTP and change the folder permission to 0777 and then you have full control over it or you have to stick with using 0755 or similar.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!