Network Solutions

OS, Ubuntu, Uncategorized

How to give apache2 permission to write and read files?

When we try to write something on apache2 normally we cannot because of permission issue. To write something or delete or edit on apache2 you need to provide proper permission on specific user.

Here is the procedure for permission on apache2 on ubuntu server 18.04

Assign Recursive WWW User & Group: (logs + html)

sudo chgrp www-data /var/www
sudo chmod 770 /var/www
sudo chmod 775 /var/www/html
sudo chmod g+s /var/www
sudo chmod g+s /var/www/html
sudo chown -R <sudo_user>:www-data /var/www

Apply File And Folder Defaults:

See more:
# -d: default, -m: modify, g:: apply to group permissions, o:: other permissions, -R: apply recursively
# set group to rwx default:
setfacl -d -m g::rwx /var/www
setfacl -d -m g::rwx /var/www/html

Reboot Server Anyway:

sudo reboot

Check Permissions

getfacl /var/www
getfacl /var/www/html
getfacl /var/www/test.txt
getfacl /var/www/html/test.txt

OR USE: FTP FileZilla or Winscp

Leave a Reply

Theme by Anders Norén