File permission problem on Ubuntu Lamp server
You were close: the directory /var/www/ should be owned by www-data (as a user) and www-data as a group. So the proper command, if things get messed up, is:
sudo chown -R www-data:www-data /var/www
Related videos on Youtube
Comments
-
alaminio almost 2 years
Please don't mark it as duplicated. I've tried a lot but can't make it working.
I've installed LAMP using tasksel. Everything is fine but having file permission error (While installing WordPress I get this error "Sorry, but I can’t write the wp-config.php file." )
I can create the file manually but I don't want to do this. I wasn't to make it working correctly.
What I did to set up permission after installing lamp
cd /var/wwww/ sudo chown -R username:www-data /var/www/html/ sudo chmod 775 /var/www/html/ sudo chmod g+s /var/www/html/
Later I tried some solutions like
sudo chown -R [USER NAME]:[USER NAME] /var/www
which I found on askubuntu.I don't know much about permission issue trying solution blindly.
Can you please help me on this to make it working? :)
Output of
ls -l /var/www
Output of total 4 drwxrwsr-x 3 h3mdsa h3mdsa 4096 Jun 12 16:40 html
(Thanks @Jos for comment)Thanks in advanced,
Md Al Amin-
Jos about 9 yearsAt this point, what is the output of
ls -l /var/www
? Please add this to your question. -
Jos about 9 yearsTry:
sudo chown -R www-data:www-data /var/www
. That should work. You were close. -
alaminio about 9 yearsHey it works like a magic. Can you please tell me why
sudo chown -R username:www-data /var/www/html/
didn't work? I used it on other machine 2 month ago. It worked but didn't work this time. Anyway thanks for help. -
Jos about 9 yearsHard to tell why that did work on the other machine - it shouldn't have worked. Apache2 runs with user name
www-data
and executes PHP statements as that user. Allow me to rewrite my comment as an answer. -
Rinzwind about 9 yearsIf Jos his answer is correct why is this NOT a duplicate? Hmm? @alamin72103 for instance: your method works but does need a change to groups: askubuntu.com/questions/353847/apache-permissions or askubuntu.com/questions/378351/… and many more ;)
-
alaminio about 9 yearsHi @Rinzwind Thanks for your comment. I told on my question that I don't know much about permission issue. The first link you gave was not helpful for me because he told "I have added the www-data user to my user's group" I didn't know anything like that so I was like an alien word to me and I tried second liked accepted answer which I mentioned on my question. But your comment helped me. I was unable to create folder and file with mouse right click. After adding www-data user to my user's group everything is fine.Thank you for your comment.
-