Enable hosting files outside /var/www in Apache2

I’m using Ubuntu and Mac OS X in my computer. I wanted both to share a partition to put all the things that could be duplicated in both systems: DropBox, downloads, music, etc. The websites I’m developing would be also there but I was getting 403 errors all the time. Anything outside /var/www won’t work. Finally I found out that there is a Directory configuration in /etc/apache2/apache2.conf that denies access to anything outside /var/www and /usr/share:

<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>

To fix this you can disable the first Directory block or even better add a new one with Require all granted in it for your speceific path:

<Directory /home/shared/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

apache_logo

You might also like

Change between multiple versions of PHP with Apache in Mac Ports
If you have for example 2 different versions of PHP in the same machine you can switch between them by...

Hide Mac OS X Recovery partition
Sometimes the Mac OS X Recovery partition can be seen because it's mounted automatically on boot. This...

Install OpenCV 2.3.1a in Ubuntu 11.10
If you want to install OpenCV 2.1 you can just use apt-get to do the work: sudo apt-get install libcv-dev...

Install OpenCV 2.3.1a in Ubuntu 11.10
If you want to install OpenCV 2.1 you can just use apt-get to do the work: sudo apt-get install libcv-dev...

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.