Setting up Apache’s file ownership and permissions

in Categories: Apache, Configuration, Web Server.


Here is how to setup the Apache web servers ownership and permissions.

Note: Remember to change the /var/www/html location to match yours.

Setting up ownership(s):

sudo chown -R www-data:www-data /var/www/html

Setting up permission(s):

sudo find /var/www/html -type d -exec chmod 755 {} \;

sudo find /var/www/html -type f -exec chmod 644 {} \;

Optional

Let say that you have a log folder inside your html folder, so you can do this.

sudo chmod -R 755 /var/www/html/log

To check the content of the log file, you can use.

tail -f /var/www/html/log/log.log