前言
SAMBA是一種能把 FreeBSD 的目錄開放給Microsoft Windows 95/98/NT 利用網(wǎng)路芳鄰方式存取的軟體集。其實(shí)并不只針對 FreeBSD,其它UN*X 也都可以使用,這對工作平臺大部分時(shí)間是Microsoft family的人在存取檔案上,會(huì)是個(gè)比較方便的選擇。
安裝SAMBA 2.0.6
1.先以 root 身份 login,切換至/usr/ports/net/samba 準(zhǔn)備安裝SAMBA。
安裝時(shí)只要在 SAMBA 的目錄下執(zhí)行 make install 即可
# root@ohaha[~] cd /usr/ports/net/samba/
# root@ohaha[/usr/ports/net/samba] make install
若無出現(xiàn)錯(cuò)誤訊息則是安裝完成,你可順手將安裝過程中解開的source清掉。
# root@ohaha[/usr/ports/net/samba] make clean
設(shè)定 SAMBA (smb.conf)
在安裝完 SAMBA 後,它會(huì)放一份設(shè)定檔例在/usr/local/etc 下, 先將例一份來修改成我們要的設(shè)定。
# root@ohaha[~] cd /usr/local/etc/
# root@ohaha[/usr/local/etc] cp smb.conf.default smb.conf
sam.conf.default是設(shè)定 SAMBA 的例檔,真正讀取的預(yù)設(shè)是 smb.conf, 為了保留原始的例檔以供日後參考用,所以我們用 cp 的方式出設(shè)定檔,大致瀏覽過 smb.conf 後發(fā)現(xiàn),它主要分成三大設(shè)定區(qū),[globe]、[homes]、 [printers],我沒有印表機(jī),所以沒機(jī)會(huì)試[printers]相關(guān)部分。
我開 SAMBA 的目地是為了方便存取管理 ftp 并使用該臺 FreeBSD 上的硬碟空間,所以等會(huì)設(shè)定檔的***終目地便是開出一個(gè)分享目錄 ftp,無須密碼,但只允許我的工作機(jī)器去存取它。
在 smb.conf 中,所有的#和;都是解。#後接的是說明,
;後接的是指令,預(yù)設(shè)不打開該項(xiàng)設(shè)定,若想讓它生效把分號拿掉即可。
以下只引出我有動(dòng)過的地方,沒提出的就是保留預(yù)設(shè)值。
#======================= Global Settings =====================================
[global]
# workgroup = NT-Domain-Name or Workgroup-Name, eg: REDHAT4
# 設(shè)定所在工作群組
workgroup = center
# server string is the equivalent of the NT Description field
# 該主機(jī)的解
server string = blah~
# This option is important for security. It allows you to restrict
# connections to machines which are on your local network. The
# following example restricts access to two C class networks and
# the "loopback" interface. For more examples of the syntax see
# the smb.conf man page
# 允許連線的主機(jī),允許 163.16.1.99 和 127.*.*.* 連線
hosts allow = 163.16.1.99 127.
# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
# 我沒有 printer ,所以有關(guān) printer 的都會(huì)關(guān)掉
; load printers = yes
# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
# 這里設(shè)定免密碼的帳號,你設(shè)什麼帳號,連進(jìn)來的 client就是那個(gè)身份,了嗎?
# 所以我把這兒改成 ftp 這個(gè)帳號,因?yàn)槲?share 出來的目錄 owner 是 ftp
# 這樣我才能以免密碼又是 ftp 的身份對目錄有完整的存取權(quán)。
# 不過記得,這兒填的帳號必須存在 /etc/passwd 中,否則會(huì)以 nobody 的身份簽入。
guest account = ftp
# this tells Samba to use a separate log file for each machine
# that connects
# 把 log 建個(gè)目錄來放比較整齊,記得去 mkdir /var/log/samba 這個(gè)目錄。
log file = /var/log/samba/log.%m
# Security mode. Most people will want user level security. See
# security_level.txt for details.
# 設(shè)定安全層級,若要不用密碼分享的話就要設(shè)成 share ,若設(shè) user 的話會(huì)要求密碼。
# 詳情請見 docs/security_level.txt
security = share
# You may wish to use password encryption. Please read
# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
# Do not enable this option unless you have read those documents
# 我的目的是不用密碼存取,所以這項(xiàng)開不開都沒影響,但若你想用密碼來控制存取權(quán)限時(shí),
# 請記得將此項(xiàng)打開,因?yàn)?..詳見 docs/ENCRYPTION.txt, Win95.txt 和 WinNT.txt。
; encrypt passwords = yes
# for Traditional Chinese Users
# 若你想看到中文目錄、檔名的話,把 client code page=950 前的分號拿掉,
# 注意,coding system 那項(xiàng)留著別打開它,兩個(gè)都打開的話反而會(huì)看不到中文
client code page=950
; coding system=cap
#============================ Share Definitions ==============================
# 接下來這一段就是 [homes] 和 [printers] 以及其它任何你想 share 出來的目錄設(shè)定
# 區(qū),我把 [homes] 也 mark 起來了,因?yàn)槲也幌?share 任何 home 出來。
;[homes-%U]
; comment = Home Directories
; path = /home/%U
; user = %U
; browseable = no
; writeable = yes
# ftp
# 我加了這段,將 ftp 的目錄開分享。一開始我們看到的 [ftp] 就是你分享出來的目錄
# 在 95/98/NT 中會(huì)看到的資料夾名稱,path 指向欲 share 目錄的******路徑,
# public = yes 是指定這個(gè)分享不須密碼,writeable = yes 是指可對該分享做寫入動(dòng)作
# 注意一點(diǎn),當(dāng)有 public = yes 這行時(shí),對該分享存取的身份就是之前在 [globe] 區(qū),
# 我們所設(shè)定 guest account 的身份,若剛剛 guest account 沒改成 ftp,那麼現(xiàn)在
# 即使有設(shè) writeable = yes 也會(huì)因?yàn)?owner 不對而無法寫入。
[ftp]
path = /home/ftp
public = yes
writeable = yes
啟動(dòng) SAMBA
在安裝完 SAMBA 後,它丟了個(gè)啟動(dòng)的 script 在 /usr/local/etc/rc.d/,檔名是 samba.sh.sample,將之更名并 chmod 成可執(zhí)行。
# root@ohaha[/usr/local/etc/rc.d] mv samba.sh.sample samba.sh
# root@ohaha[/usr/local/etc/rc.d] chmod 750 samba.sh
你現(xiàn)在可以重新開機(jī)或者手動(dòng)執(zhí)行 samba.sh 來啟動(dòng) SAMBA。
# root@ohaha[~] /usr/local/etc/rc.d/samba.sh
測試 SAMBAuh...接下來的不用說了吧,趕快用 95/98 的網(wǎng)路芳鄰看看是否能成功看到并存取分享出來的目錄。
(http://www.fanqiang.com)