我最近在我的服务器上设置了Capistrano,而且效果很好。
我改变了我的虚拟主机,指向由Capistrano创build的符号链接。
我的虚拟主机文件:
<VirtualHost *:80> DocumentRoot /var/www/html/my_app.com/current ServerName my_app.com <Directory /> Options FollowSymLinks AllowOverride Indexes </Directory> </VirtualHost>
当我重新启动我的Apache服务器使用sudo service httpd restart ,我得到的错误:
Warning: DocumentRoot [/var/www/html/my_app.com/current] does not exist
current目录肯定存在。 当我设置虚拟主机指向.../my_app.com/ ,它的工作原理和显示默认的apache页面,问题是这个符号链接到current (这是更新为我部署应用程序使用capistrano)。
我使用的是Amazon EC2实例,Apache 2.2(LAMP)。
所以基本上,我如何将一个虚拟主机指向一个符号链接?
更新 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
在我的httpd.conf (注释除去):
<Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all </Directory>
我的错误日志:
[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/
ls -l的输出为/var/www/html/my_app.com/releases/20120828223949 。
drwxrwxr-x 6 ec2-user ec2-user 4096 Aug 28 22:39 20120828223949
当我运行命令ls -l /var/www/html/my_app.com/current/
ls: cannot access /var/www/html/my_app.com/current/: No such file or directory
看起来像一个死的符号链接…我如何解决这个问题?
按照我的评论和你的后续,它看起来像你current符号链接不指向一个有效的目标; 删除它并重新添加它:
$ rm -f /var/www/html/my_app.com/current $ ln -s /var/www/html/my_app.com/{releases/20120828223949,current}