Ubuntu – CHMOD folder permissions to access by http

Apache2chmodpermissions

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?

Best Answer

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.

Related Question