
我最近在我的伺服器上安裝了 Capistrano,效果很好。
我更改了虛擬主機以指向 Capistrano 創建的符號連結。
我的虛擬主機檔案:
<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
for的輸出/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
看起來像一個死符號連結...我該如何解決這個問題?
答案1
根據我的評論和您的後續行動,您的current
符號連結似乎沒有指向有效的目標;刪除它並重新添加它:
$ rm -f /var/www/html/my_app.com/current
$ ln -s /var/www/html/my_app.com/{releases/20120828223949,current}