Monday, 7 June 2021

Apache default directory access, and how to allow for other directory access

 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.

The default Ubuntu document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.



Allow more directory access :

 vim /etc/apache2/apache2.conf.

Require all grant meaning allow access

Options FollowSymLinks means symbolic link can be established


<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>





wq!

sudo service apache2 restart


// If only want /var/www access , can set up folderA in /var/www for symlink access to other directory, need to 


https://askubuntu.com/questions/843740/how-to-create-a-symbolic-link-in-a-linux-directory


ln -s /var/www/vhosts/ecash_cfe /var/www/vhosts/ecash-staging.com/ecash_root
  • -s stands for symbolic link

  • /var/www/vhosts/ecash_cfe is the source file

  • /var/www/vhosts/ecash-staging.com/ecash_root is the link name


No comments:

Post a Comment