2

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

2 Answers2

9

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

Jos
  • 30,529
  • 8
  • 89
  • 96
0

You need to change the group of the web files to your Linux user name or at least add user 'root' to the group "www-data"

usermod -a -G www-data root

There is also a three-step technique by which you can solve this:

Those three are in the link below. This post can solve the full problem.

https://www.spookycodes.com/2019/11/09/fix-linux-lamp-server-permission-issues-ultimate-fix-2020/