我是武男, 24歲, 大家都叫我阿男...有的人還會叫我白目研究生...

Apache DocumentRoot on NFS How To

Autor 白目研究生

這次的需求如下,家裡面NAT底下有兩台機器:

FreeNAS:File Server on FreeBSD support CIFS、FTP

Web Server:Appserv 2.5.9 on Windows XP support Web、Ftp service

第一個版本的架構如下(理想的理論):

Web Server建立CIFS的連線磁碟機(Z:\),後把Aappserv的DocumentRoot指到網路磁碟機上。

也就是所有的網頁目錄都會被建立在FreeNAS上,而 Web Server則只是個跳板,除了一般的IPTable安全性設置,相關網頁目錄存取權限,則是被FreeNAS監控。

But

Appserv的httpd.conf 設定上可沒那麼好說話,單純設定“DocumentRoot “\\CIFS IP or Z:\”

就會出現設定檔的字元是不合法的“The Requested Operation Has Failed!”的訊息提示,並且不允許重新啟動httpd的process

今天詢問ychsiao長輩的結果:阿就,Windows才會這樣阿,換掉換掉。

Salamand長輩:對阿,真奇怪,17:00跟5:00 PM明明就一樣阿,怎麼會少了兩個小時。38l34mor5

找了一下,在Windows底下安裝NFS Service,有沒有這麼麻煩,我看還是算了。0m618aako

後來實際測試,確定可行的架構就變成了這樣子

FreeNAS:File Server on FreeBSD support CIFS、FTP、NFS

Web Server:Web Server on FreeBSD support 要什麼有什麼

在FreeBSD底下要使用NFS service 的環境是需要NFS Client的,可以透過下面方式啟動。

在/etc/rc.conf底下設定開機啟動nfs client與rpc

nfs_client_enable=”YES”
#nfs_server_enable=”YES”
nfs_client_flags=”-n 4″ # Flags to nfsiod (if enabled)
nfs_access_cache=”2″ # Client cache timeout in seconds:00 des Exp $
#nfs_server_flags=”-u -t -n 8″ # Flags to nfsd (if enabled).#
rpc_lockd_enable=”NO” # Run NFS rpc.lockd needed for client/server.
rpc_statd_enable=”YES” # Run NFS rpc.statd needed for client/server.
rpcbind_enable=”YES” # Run the portmapper service (YES /NO).

之後,檢查FreeNAS share出來的檔案目錄

#showmount -e FreeNA_IP

可以得到以下資料Table

Exports list on FreeNA_IP:
/mnt/MASTER 210.71.23.0

用下面指令把NFS目錄mount 在Web Server上

#mount -t nfs 210.71.11.227:/mnt/sharename /mnt

如果要解除這個目錄的話,只要#umount /mnt 這樣子就可以了

接著就是#mount 檢查NFS目錄有沒有被掛上去

會看到下面info

/dev/da0s1a on / (ufs, local)
devfs on /dev (devfs, local)
/dev/da0s1g on /home (ufs, local, soft-updates)
/dev/da0s1f on /tmp (ufs, local, soft-updates)
/dev/da0s1d on /usr (ufs, local, soft-updates)
/dev/da0s1e on /var (ufs, local, soft-updates)
devfs on /var/named/dev (devfs, local)
Jupiter:/vol/freebsd on /nas (nfs)

確定有mount起來就可以開始編輯httpd.conf的設定了

#ee httpd.conf

add DocumentRoot “/mnt”

之後restart apache就可以看到測試了,不過你會先看到You don’t have permission to access / on this server.

這個就真的無解了,因為設定不知道為什麼會先讀到/這個目錄,不過可以修正httpd.conf解決這個問題

把下面通通註解掉即可

<Directory />
AllowOverride None
Order deny,allow
Deny from all
</Directory>

restart apache後就可以重新測試了。

參考資料:

http://turtle.ee.ncku.edu.tw/~ac/FreeBSD/50_NFS/nfs.html

http://www.bsdmap.com/mirrors/fanqiang/www.fanqiang.com/a1/b2/20010419/144107_b.html

http://docs.hp.com/zh_tw/B2355-90952/ch04s04.html

結論:阿就,Windows才會這樣阿,換掉換掉。

Reader's Comments

  1. ychsiao |

    AllowOverride None
    Order deny,allow
    Deny from all

    這段註解掉會有問題….
    你應該是新增nfs path的directory權限設定

  2. ychsiao |

    順便一提,我只是要找apache2跟NFS效率教調的設定= =

  3. heaven |

    oops, 受教了!!

  4. ychsiao |

    知道問題所在嗎?:p

  5. heaven |

    測試環境已經撤掉了…

    所以還沒測到學長說的問題…

    不過推估跟是APACHE跟某個程序權限是有關連的

    不知道專為NFS的目錄多一個的規則能不能解

  6. 花开 |

    请将aa.shangdu.com改为:http://www.bsdmap.com/mirrors/fanqiang/www.fanqiang.com/a1/b2/20010419/144107_b.html

CommentComment