看板 Knuckles_note
作者 標題 [Apache] 設定 FollowSymLinks 啟用目錄連結
時間 2014年05月04日 Sun. AM 03:57:55
若使用者的網頁目錄為 /home/knuckles/public_html/
網址為 http://xxx.xxx.xxx/
在裡面有使用 link 連結至其他地方的目錄,例如 /home/share/
$ ln -s /home/share/ /home/knuckles/public_html/share
如果想要讓網頁可以使用 http://xxx.xxx.xxx/share/ 讀取這個目錄的話
要在 virtual host 的 Directory 設定加上 Options FollowSymLinks
並且把另一個目錄也加上 Directory 的設定
例如:
<VirtualHost *:80>
DocumentRoot /home/knuckles/public_html
ServerName xxx.xxx.xxx
<Directory /home/knuckles/public_html>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /home/share>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
注意要設定讓 apache 有讀取 /home/share 的權限
注意 link 檔的擁有者必需與 /home/share 的擁有者相同
要用 chown -h 才能改 link 檔的擁有者,不然會改成目標目錄的擁有者
例如 /home/share 目錄的擁有者為 share
$ chown -h share /home/knuckles/public_html/share
--
※ 作者: Knuckles 時間: 2014-05-04 03:57:55
※ 編輯: Knuckles 時間: 2014-05-04 08:20:53
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 686
回列表(←)
分享