Welcome Guest, Not a member yet? Register   Sign In
Message: mkdir(): Permission denied
#13

(This post was last modified: 09-30-2015, 11:52 AM by jLinux.)

(09-30-2015, 11:36 AM)Lykos22 Wrote:
(09-30-2015, 09:28 AM)jLinux Wrote:
Code:
man chmod
Code:
chmod -R 755 /path/to/folder
or if you're SURE this is ok..



Code:
chmod -R 777 /path/to/folder

I run


Code:
chmod -R 777 /opt/lampp/htdocs/www/my-app/public/uploads

and worked! the script created the posts folder.

However I tried 755 or 775 instead but didn't work, the warning popped up again. Is there a way I can make this work with 755 or 775 permissions, because 777 is not so secure.


Just make sure that the folder is either owned by whatever is running the web service..

If you dont know what the user is, then use the lsof command to check it out. heres an example (assuming that its port 80)
Code:
[root@server ~]# lsof -i:80
COMMAND   PID       USER   FD   TYPE     DEVICE SIZE/OFF NODE NAME
httpd    4588     apache    3u  IPv4 4164112702      0t0  TCP *:http (LISTEN)
httpd    4592     apache    3u  IPv4 4164112702      0t0  TCP *:http (LISTEN)
httpd    8170     apache    3u  IPv4 4164112702      0t0  TCP *:http (LISTEN)
httpd    8171     apache    3u  IPv4 4164112702      0t0  TCP *:http (LISTEN)
httpd   24021     apache    3u  IPv4 4164112702      0t0  TCP *:http (LISTEN)

So I can see that my user is apache. But if that somehow confuses you, then run this:
Code:
[root@server ~]# lsof -i:80 | sed 1d | awk '{print $1}' | sort -u
httpd
That will tell you what user is working. It may come up with more than 1 user if multiple services are listening on port 80.


So either chown the folder and its contents to apache (or whatever user)..
Code:
chown -R apache /opt/lampp/htdocs/www/my-app/public/uploads
You might need to elevate your access to do this, by adding sudo before the chown in the command.

If you cant change the owner for the folder, then try the group, just make sure its a group that you and the apache/web user have in common:
Code:
chown -R :groupname /opt/lampp/htdocs/www/my-app/public/uploads

Then change the perms to 775, so both the owner and group have all perms, but everyone else just has read/exec
Code:
chmod -R 775 /opt/lampp/htdocs/www/my-app/public/uploads

You can try to set the group owner of the uploads file to the web user, see if that works... havent tried that before.


P.S. If this wasnt clear from the above. ALL of those commands are via the shell, meaning the command line.. NOT via PHP scripts running exec(). I cant imagine that would work out.
Reply


Messages In This Thread
Message: mkdir(): Permission denied - by Lykos22 - 09-29-2015, 03:13 PM
RE: Message: mkdir(): Permission denied - by jLinux - 09-30-2015, 11:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB