[測試] 安裝NFS伺服器、SMB伺服器及vsftpd全紀錄

本帖最後由 pipikeung 於 2025-2-2 07:54 編輯

安裝NFS伺服器、SMB伺服器及vsftpd,全紀錄

已安裝好網站,該站裝在老舊的小電腦內(半廢物利用),放在家中的不顯眼一角,若要利用來作全屋同網層的儲存中心,必需安裝nfsd,使與使用Linux OS的主機分享資料,同時裝smbd,使與Windows作業系統主機相互溝通。要上載及下載資料,安裝vsftpd更不可少。

01 安裝NFS伺服器
   

安裝nfs-kernel-server

sudo apt-get install nfs-kernel-server -y

匯出資料夾
#sharedfolder是分享資料夾,分享資料給同網層的Liunx OS主機
sudo mkdir /mnt/sharedfolder

在/etc/exports中,加入以下內容:
/mnt /sharedfolder 192.168.1.0/24(rw,no_root_squash,no_subtree_check)

sudo chown -R nobody:nogroup /mnt/sharedfolder
sudo chmod 777 /mnt/sharedfolder
sudo exportfs -ra

掛載NFS
在客戶端
sudo mkdir /mnt/nfs_sharedfolder
sudo apt-get install nfs-common -y
sudo mount -t nfs 192.168.1.100:/mnt/sharedfolder /mnt/nfs_sharedfolder
(nfs伺服器假設在192.168.1.100)

若要開機自動掛載,在客戶端/etc/fstab下,加入下列一句﹕
192.168.1.100:/mnt/sharedfolder /mnt/nfs_sharedfolder nfs rw,x-gvfs-show,user

從新啟動客戶端便自動掛載﹗

(截圖顯示linux OS中的nfs_sharefolder為可共享的資料夾)


(在Windows 10中可見到sharedfolder是nfsd分享出來的資料夾)

02 安裝samber伺服器與Windows共享資料

在Linux上安裝samba server

sudo apt-get install samba

編輯/etc/samba/smb.conf

使用nano作文字編輯器﹕

sudo nano /etc/samba/smb.conf

在檔案最後端加上﹕

security = share

[share]
comment = share
path = /home/yourname/yourfolder
available = yes
browsable = yes
public = yes
writable = yes
create mask = 0777

儲存後退出,(^O ^W)

將分享的資料夾,設定為nobody:nogroup及權限為0777

sudo chown -R nobody:nogrpup /home/yourname/yourfolder
sudo chown -R 777 /home/yourname/yourfolder

重啟samber server
sudo service smbd restart

開啟windows 10在網絡中便可以使用共享的資料夾

(share是smbd分享出來的資料夾)

03 安裝vsftpd

安裝vsftpd十分簡單,安裝後修改/etc/vsftpd.conf來設合自己需要便可了。

sudo apt-get install -y vsftpd

修改vsftpd.conf﹕

sudo nano /etc/vsftpd.conf
如何設定網上有海量資訊,不作詳述。但建議﹕

  不給anonymous使用,只開放有賬號使用者
   anonymous_enable=NO
   local_enable=YES

  支緩中文字型
  utf8_filesystem=YES

最後重新啟動﹕sudo service vsftpd restart

在linux OS客戶端安裝Filezilla,連入vsftpd
sudo apt-get install filezilla
連入vsftpd的情況截圖﹕


Windows OS客戶端,直接下載filezilla的安裝檔安裝便可

在客戶端上使用多媒體播放器,便可播放放在nfsd或smbd內的媒體檔案,包括視頻,音頻、相集.....、這樣便實現成為多媒體儲存中心。

由零開始至建成加密網站再成為多媟體儲存器,大略分成5個步驟﹕
01 安裝作業系統(Linux OS)
02 安裝LAMP
03 使用Drupal/Wordpress搭建網站
04 使用LetsEncrpt為網站加密成為(https)
05 安裝vsftpd、nfsd、smbd使能與Linux及Windows作業系統溝通共享資料。

以上各階段都走過一遍亦在此大略介紹過,當然網站還有無限的可能性,透過安裝不同的Deamons來實現﹗希望各位「大大」提出意見,多加指正。

i also reinstall nfs in my server, in my config, a usb external drive will be mounted and exported, clients will be connected to nfs with wifi. i found two problems with this config.
1) external drive is slow to mount and nfs will fail with mount point not found error.
2) clients can not found nfs mount point because wifi is connected after nfs service.
for problem 1) make sure mount service finish before nfs.
for 2) i have to change the parameter of the very bottom program nm-online

TOP

i also reinstall nfs in my server, in my config, a usb external drive will be mounted and exported,  ...
chancho 發表於 2020-12-23 06:13


/etc/fstab設計係預你放D永遠存在既野, e.g. local, lan, iSCSI, FC......
Wi-Fi先連到既唔應該放入去mount

另外, 如果真係要用Wi-Fi行NFS的話, 請檢查係咪行緊NFS v3或以上 + 用緊TCP
用UDP經Wi-Fi肯定斷到傻
(留意, NFS Mount後如果斷左wi-fi, 係會一load相關既野就hang機)
https://stackoverflow.com/questi ... -use-udp-by-default
NFS was originally designed to be used on a LAN where loss rates are very low.

TOP

仲用NFS SMB 快改用 SSHFS la
windows SSHFS Client
https://github.com/billziss-gh/sshfs-win

TOP