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?
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 likeapache
You can then update httpd.conf, adding in these two lines (reloading the config after):
Then, run
chown apache:apache -R dir_name
to make apache own it.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.
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.