Message: mkdir(): Permission denied |
(09-30-2015, 09:28 AM)jLinux Wrote: 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. (09-30-2015, 11:36 AM)Lykos22 Wrote:(09-30-2015, 09:28 AM)jLinux Wrote: 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 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 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 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.
I have to start the procedure from the begining. When the page loads for first time in my Post_model I have this script
PHP Code: // set up the folder for storing images and thumbnails Code: /opt/lampp/htdocs/www/my-app/public/uploads/posts$ ls -lah which pretty much doesn't allow me to delete them. If it do Code: sudo chown -R lykos /opt/lampp/htdocs/www/my-app/public/uploads Then I can easily delete images and the folders if I want to. But if I try to upload another image the upload library shows me the error that the folder is not writeble and doesn't let me upload. I really don't understand what's going on .. do I have to set the hole php script that creates the folders and uploads images to a user (lykos) or some group and change some permissions too ?? I 'm completely confused..
What does $_ENV["USER"]; say?
Did some research, are you on a shared server? I doubt it, or else you couldn't run the commands you have ran, unless you are in a jailshell If you aren't on a shared server, try disabling safe mode.. (09-30-2015, 03:43 PM)jLinux Wrote: What does $_ENV["USER"]; say? null no I'm on my local machine
P.S.
You seem surprised by the fact that when YOU run some commands (chmod) via the command line, it works, as opposed to when you run the commands via PHP exec(), which dont work. You realize the commands you run via shell are being ran as a totally different user, right? Im just saying that because your "It worked!" statement seemed like you were surprised, but you shouldnt be. (09-30-2015, 03:48 PM)Lykos22 Wrote:(09-30-2015, 03:43 PM)jLinux Wrote: What does $_ENV["USER"]; say? Can you provide me a phpinfo by any chance? And maybe the output of: Code: lsof -i:80 (09-30-2015, 03:49 PM)jLinux Wrote: P.S. Yes it seems like that, but in this case which is the correct one ??? What user and what permissions should have my uploads, my posts and my thumbnails folders to work properly ??? (09-30-2015, 03:56 PM)Lykos22 Wrote:(09-30-2015, 03:49 PM)jLinux Wrote: P.S. Well I guess its not as important that the web user not be the same as your local user when running locally, but I still highly recommend against it... So lets debug it and fix it the right way! Ill help you debug it. Can you provide me a phpinfo() output by any chance? And maybe the output of: Quote:lsof -i:80 as well as: Quote:ps aux |grep -i [h]ttp And this is Apache were working with right? not nginx or anything else? |
Welcome Guest, Not a member yet? Register Sign In |