- # This file controls the state of SELinux on the system.
- # SELINUX= can take one of these three values:
- # enforcing - SELinux security policy is enforced.
- # permissive - SELinux prints warnings instead of enforcing.
- # disabled - No SELinux policy is loaded.
- SELINUX=enforcing #這裏改成disabled
- # SELINUXTYPE= can take one of these two values:
- # targeted - Targeted processes are protected,
- # mls - Multi Level Security protection.
- SELINUXTYPE=targeted
注:這裏我只不過把它全整個關掉,samba中如何設置Selinux參見:http://fedoraproject.org/wiki/SELinux/samba
第二步:安裝Samba及Swat
[root@localhost ~]# yum install -y samba-*
[root@localhost ~]# rpm -qa|awk '/samba/'
- samba-winbind-clients-3.5.10-115.el6_2.x86_64
- samba-swat-3.5.10-115.el6_2.x86_64 #SWAT包也安裝成功了
- samba-3.5.10-115.el6_2.x86_64
- samba-domainjoin-gui-3.5.10-115.el6_2.x86_64
- samba-winbind-devel-3.5.10-115.el6_2.x86_64
- samba-common-3.5.10-115.el6_2.x86_64
- samba-winbind-3.5.10-115.el6_2.x86_64
- samba-doc-3.5.10-115.el6_2.x86_64
- samba-client-3.5.10-115.el6_2.x86_64
- samba-winbind-krb5-locator-3.5.10-115.el6_2.x86_64
[root@localhost ~]# yum install xinetd* #安裝它是通過xine服務來啓動SWAT
[root@localhost ~]# vi /etc/xinetd.d/swat
- # default: off
- # description: SWAT is the Samba Web Admin Tool. Use swat \
- # to configure your Samba server. To use SWAT, \
- # connect to port 901 with your favorite web browser.
- service swat
- {
- port = 901
- socket_type = stream
- wait = no
- only_from = 0.0.0.0 #默認是127.0.0.1
- user = root
- server = /usr/sbin/swat
- log_on_failure += USERID
- disable = no #默認是YES
- }
[root@localhost ~]# service xinetd restart #重啓xinetd,並啓動Swat服務
[root@localhost ~]# netstat -lnpt|awk '/901/' #查檢901端口是否開放
- tcp 0 0 :::901 :::* LISTEN 9880/xinetd
第三步:登錄SWAT (切記:iptables裏面開放901或關閉iptables)
輸入你的IP加901端口號,登錄帳號是ROOT出現如下界面證明你配置成功了。
[root@localhost ~]# useradd smbuser #創建用戶
[root@localhost ~]# smbpasswd -a smbuser #提升用戶
[root@localhost ~]# mkdir /usr/local/share_dir #創建共享目錄
[root@localhost ~]# chown smbuser:smbuser -R /usr/local/share_dir/ #設置權限
創建共享目錄
設置共享目錄
設置完成以後需要重起Samba服務
第四步:Samba調式講解
1:smbpasswd 命令創建的用戶數據存在哪兒
答:[root@localhost ~]# smbd -b | grep PRIVATE_DIR
PRIVATE_DIR: /var/lib/samba/private
2:Samba的主配置文件smb.conf在哪兒
答:[root@localhost ~]# smbd -b | grep smb.conf
CONFIGFILE: /etc/samba/smb.conf
3:Samba如何檢查配置是否正確
答:[root@localhost ~]# testparm -s /etc/samba/smb.conf
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Loaded services file OK.
Server role: ROLE_STANDALONE
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
browseable = No
參考文檔
http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/
http://www.samba.org/samba/docs/man/Samba-Guide/
http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/SWAT.html