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?


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.

| improve this answer | |
  • 1
    I try chmod 711 to mysite and worked. – FrozenButcher Jul 25 '13 at 10:45
  • I'v try @Carster solution and when I access my http page I get a blank page – FrozenButcher Jul 25 '13 at 10:49
  • Strange. Are you running Apache as web server? The specific commands I wrote will only work if your web server is running as www-data. – Carsten Agger Jul 25 '13 at 12:13

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.

| improve this answer | |

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.