views:

54

answers:

3

Hi,

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?

A: 

I wouldn't go that route, just give it permissions to the defined upload_tmp_dir, or define upload_tmp_dir to be a directory you have access to. If it is that directory you have problems with. If the target is the problem, and you've 777'ed it, something fishy is going on.

Wrikken
I've 777'ed it and it upload fine.. But my script then uses Chmod and Rename which also get permission denied.. I need the script to have owner permissions.
Moe
A: 

Do you have ssh access to your new host? The reason I ask is that it's probably not best to use the username/group as nobody, as most other services would use this too. I would change it to something like apache

You can then update httpd.conf, adding in these two lines (reloading the config after):

User apache
Group apache

Then, run chown apache:apache -R dir_name to make apache own it.

Cetra
A: 

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.

Starx