15

I want to setup a local web server on my Ubuntu (14.04). So I installed all software to get a LAMP server.

The problem is that I do something wrong with creating my virtualhosts. I wanted to create different subdomains on my localhost. So for example site1.localhost and site2.localhost.

In my /var/www/ directory I created a symbolic link "site1" going to /home/user/Workspaces/site1.

In my Apache error.log file I got the following error.

[core:error] [pid 12679] [client 127.0.0.1:59006] AH00037: Symbolic link not allowed or link target not accessible: /var/www/site1

In my apache configuration I have:

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

So I think there is something wrong with the permissions of the folders. I searched on Google and I found a few people with the same problem but all answers provided there didn't work out. I added my own username tot the www-data group and things like that.

So ls -la /var/www returns:

total 12
drwxrwsr-x  3 user www-data 4096 okt 13 19:08 .
drwxr-xr-x 14 root root     4096 okt  1 22:50 ..
drwxr-xr-x  2 root www-data 4096 okt  1 22:50 html
lrwxrwxrwx  1 root www-data   29 okt 13 19:08 site1 -> /home/user/Workspaces/site1/

and ls -la /home/juul/Workspaces/site1 returns:

total 24
drwxrwxr-x 4 user www-data 4096 okt 13 18:21 .
drwxrwx--- 3 user user     4096 okt 13 17:31 ..
-rw-rw-r-- 1 user user        0 okt 13 18:21 index.html
drwxrwxr-x 4 user www-data 4096 okt 13 16:12 .metadata
drwxrwxr-x 5 user www-data 4096 okt 13 16:53 Project

Hopefully someone can help me out with this :-)

user300279
  • 181
  • 1
  • 1
  • 5

3 Answers3

5

These permissions are preventing apache from accessing you

drwxrwx--- 3 user user     4096 okt 13 17:31 ..

You need to give execute permissions for others:

chmod o+x /home/juul/Workspaces/

(and perhaps on /home/juul/ as well).

muru
  • 197,895
  • 55
  • 485
  • 740
  • as per @muru answer, ensure that all the containing directory have the "x" permission set. If one does not have then it will never work – dawez Aug 25 '15 at 14:58
3

I have a standard apache install on 14.04. There are no files or directories specifying "www-data". Did you change all these yourself? There is a lot of outdated or simply incorrect information on how to set up web servers, so be careful who you follow, and undo what doesn't work.

That said, "site1" should be in the html directory, and owned by you. It doesn't really need to be a symlink; you can specify a different directory in the config file. Something like this:

# Add this to the end of the existing 000-default.conf file (after "</VirtualHost>")
<VirtualHost *:80>
    <Directory  /home/user/Workspaces/site1>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    DocumentRoot /home/user/Workspaces/site1
    ServerName site1
</VirtualHost>
Marty Fried
  • 18,466
2

Solution for: Symbolic link not allowed or link target not accessible: /var/www/html/mySymbolicLink.

This clearly is a problem with the permissions. The problem is that the html under your home directory is owned by your user, and the apache server is run by another user so therefore cannot access your home directory.

The solution then would be adding the user running apache to your group, normally the same as your username. So, in my CentOS box I did it as:

sudo usermod -a -G dev apache

So this add the user apache to the group dev. Now i need to give execution permissions.

In /home:

chmod g+x dev -R

This will grant execution permission to my folder only for the members of group. And thats it. You will need to modify the Apache user for whatever is running your web server, I believe for Ubuntu the user is www-data.

kenorb
  • 10,347