Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have recently setup Capistrano on my server and it works great.
I changed my virtual hosts to point to the symbolic link created by Capistrano.
My virtual hosts file:

<VirtualHost *:80>
    DocumentRoot /var/www/html/my_app.com/current
    ServerName my_app.com
    <Directory />
    Options FollowSymLinks
        AllowOverride Indexes
    </Directory>
</VirtualHost>

When I restart my apache server using sudo service httpd restart, I get the error:

Warning: DocumentRoot [/var/www/html/my_app.com/current] does not exist

The current directory definitely exists. When I set the vhost to point to .../my_app.com/, it works and shows the default apache page, the problem is this symbolic link to current (which is updated as I deploy applications using capistrano).

I am using a Amazon ec2 instance, apache 2.2 (LAMP).

so basically, how do I point a virtual host to a symbolic link?


Update The output of ls-l:

lrwxrwxrwx 1 ec2-user ec2-user   57 Aug 28 22:40 current -> /var/www/html/my_app.com/releases/20120828223437
drwxrwxr-x 3 ec2-user ec2-user 4096 Aug 28 22:40 releases
drwxrwxr-x 6 ec2-user ec2-user 4096 Aug 28 16:01 shared

In my httpd.conf(comments stripped out):

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order allow,deny
    Allow from all
</Directory>

My Error Logs:

[Wed Aug 29 00:04:39 2012] [error] [client 87.194.51.136] Symbolic link not allowed or link target not accessible: /var/www/html/my_app.com/current
[Wed Aug 29 00:04:40 2012] [error] [client 128.30.52.73] Symbolic link not allowed or link target not accessible: /var/www/html/my_app.com/current
[Wed Aug 29 00:04:40 2012] [error] [client 87.194.51.136] Symbolic link not allowed or link target not accessible: /var/www/html/my_app.com/current, referer: http://mydomain.com/

The ouput of ls -l for /var/www/html/my_app.com/releases/20120828223949.

drwxrwxr-x 6 ec2-user ec2-user 4096 Aug 28 22:39 20120828223949

When I run the command ls -l /var/www/html/my_app.com/current/

ls: cannot access /var/www/html/my_app.com/current/: No such file or directory

Looks like a dead symlink... How do i fix this?

share|improve this question
2  
Can you provide us with the output of ls -l /var/www/html/my_app.com/? At any rate, you should probably know that using symlinks in this way can lead to problems. –  brain99 Aug 28 '12 at 23:36
    
This can be permission on one of the sub-folders of the destination of the link, as symlink is always rwxrwxrwx, so you need to grant your apache access to it. –  Andrew Smith Aug 28 '12 at 23:36
2  
Does the apache user (I assume apache runs as user ec2-user) have execute permissions on /var/www/html/my_app.com/releases/20120828223437 and all parent directories? –  brain99 Aug 29 '12 at 3:46
1  
Unless you've redeployed between edits, your problem is a dead symlink. current is pointing at a directory ending 223437, and your releases directory contains a directory ending 223949. –  nickgrim Aug 29 '12 at 10:01
1  
Does ls -l /var/www/html/my_app.com/current/ (note trailing slash) return what-you-expect? –  nickgrim Aug 29 '12 at 10:05

1 Answer 1

up vote 1 down vote accepted

As-per-my-comment and your follow-up it looks like your current symlink doesn't point to a valid target; remove it and re-add it:

$ rm -f /var/www/html/my_app.com/current
$ ln -s /var/www/html/my_app.com/{releases/20120828223949,current}
share|improve this answer
    
Thanks! I ran rm -f /var/www/html/my_app.com/current && ln -s /var/www/html/my_app.com/releases/20120828223949 /var/www/html/my_app.com/current and it worked! –  JustAnil Aug 29 '12 at 12:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.