How to whitelist a directory in apache

13,170

You cannot and shouldn't serve from the /root directory. It is accessible only by the root user while Apache is running with user www-data. Take a look at the error log, and you'll see that Apache complains about permissions:

tail -f /var/log/apache2/error.log

If you are working with the root user on your system anyway, then you should upload files directly inside /var/www/html, since you already have permissions there.

Share:
13,170

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    Files that I want to serve via browser are located at /root/my_folder (ubuntu 14.04). I changed a path from /var/www/html to /root/my_folder in /etc/apache2/sites-available/000-default.conf, after that I get forbidden error when I try to access it in browser.

    Apache default welcoming page states that:

    By default, Ubuntu does not allow access through the web browser to any file apart of those located in /var/www, public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as in /srv) you may need to whitelist your document root directory in /etc/apache2/apache2.conf.

    How do I whitelist my root directory in /etc/apache2/apache2.conf, what syntax do I use?

    • cscracker
      cscracker almost 9 years
      Serving HTTP from /root/ is a really bad idea. Is there some pressing reason you can't just use /var/www?
    • Jenny D
      Jenny D almost 9 years
      The information about how to map URLs to the file system is available at httpd.apache.org/docs/2.2/urlmapping.html . However, as @cscracker said, serving anything from /root is not recommended.