CHMOD folder permissions to access by http

60,049

Solution 1

By default, Apache on Ubuntu runs as www-data.

Let's assume your folder is located in /var/www/mysite.

You can do this:

chown -R www-data:www-data /var/www/mysite
chmod -R og-r /var/www/mysite

After doing this, www-data (the Web server) will have full access to the site's files, while other non-root users will have no access at all.

If you wish to allow select users to access the site, you can make the folder group-readable and add those users to the group www-data.

Solution 2

Probably what will work is running your webserver under a dedicated user, have that user be the owner of the folder, and then chmod 700 the folder.

Solution 3

chmod 711 Worked for me. I found this useful tool that help me a loot understanding CHMOD http://www.javascriptkit.com/script/script2/chmodcal.shtml

Share:
60,049

Related videos on Youtube

FrozenButcher
Author by

FrozenButcher

I love computers, code and life.

Updated on September 18, 2022

Comments

  • FrozenButcher
    FrozenButcher over 1 year

    I have this ubuntu web server and I want to give permissions to access only by http but I don't want the folder to be visible to the network users. I have a subfolder were users upload some files and I want to hide that too. Can I do it with CHMOD? How?

  • FrozenButcher
    FrozenButcher almost 11 years
    I try chmod 711 to mysite and worked.
  • FrozenButcher
    FrozenButcher almost 11 years
    I'v try @Carster solution and when I access my http page I get a blank page