0

I have a standard user on an Ubuntu 22.04 Desktop VM named "user1". The VM is running apache2.

I would like user1 to not be able to access the contents of the folder /var/wwww to keep the contents secure. A visitor to the webpage should still be able to access the site as expected.

My attempted solution was

sudo chmod 770 /var/www

thinking that this would prevent user1 from accessing the contents. Well, that worked, but now visiting the webpage produces a "forbidden" error from Apache. Makes sense.

What is the proper way to set these permissions?

1 Answer 1

1

You need to set at least the group for user www-data, which is the group of the user of the apache process.

sudo chgrp -R www-data /var/www
sudo chmod -R o-rwx,g+rX /var/www

If already working as root, sudo is not needed (thanks for the comment)

1
  • Thank you! Worked perfectly. For those following along, make sure you type "sudo" before these commands if you are not root. Sep 18, 2022 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .