首页 » 操作系统 » Linux » CentOS 6.3下Samba服务器的安装与配置

CentOS 6.3下Samba服务器的安装与配置

 

Samba是一个能让Linux系统应用Microsoft网络通讯协议的软件,而SMB是Server Message Block的缩写,即为服务器消息块 ,SMB主要是作为Microsoft的网络通讯协议,后来Samba将SMB通信协议应用到了Linux系统上,就形成了现在的Samba软件,使得Linux与Windows之间的共享可以互相访问。
 
系统环境:
系统平台:CentOS release 6.3 (Final)
Samba版本:samba-3.0.33-3.39.el5_8
Samba Server IP:192.168.0.20
 
安装配置步骤:
1、暂时关闭iptables,或开放UDP:137 UDP:138 TCP:139 TCP:445这4个端口

[root@localhost /]# iptables -F

2、yum安装samba

[root@localhost /]# yum install samba samba-client samba-swat

3、查到安装状况

[root@localhost /]# rpm -qa | grep samba
samba-3.0.33-3.39.el5_8
samba-common-3.0.33-3.39.el5_8
samba-swat-3.0.33-3.39.el5_8
samba-client-3.0.33-3.39.el5_8

4、启动Samba服务

[root@localhost /]# service smb start/stop/restart

5、设置开机自启动

[root@localhost /]# chkconfig --level 35 smb on

6、配置samba
Samba的主配置文件为/etc/samba/smb.conf
具体配置见smb.conf模板文件

#======================= Global Settings =====================================
[global]             //该设置与Samba服务整体运行环境有关,它的设置项目针对所有共享资源
# ----------------------- Network Related Options -------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to the hostname
workgroup = WORKGROUP                  //定义工作组,也就是windows中的工作组概念
server string = HMJ Samba Server Version %v    //定义Samba服务器的简要说明
netbios name = HMJSamba               //定义windows中显示出来的计算机名称
# --------------------------- Logging Options -----------------------------
#
# Log File let you specify where to put logs and how to split them up.
log file = /var/log/samba/log.%m          //定义Samba用户的日志文件,%m代表客户端主机名
# ----------------------- Standalone Server Options ------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)
security = share                    //共享级别,用户不需要账号和密码即可访问
#============================ Share Definitions ==============================
[public]                     //设置针对的是共享目录个别的设置,只对当前的共享资源起作用
comment = Public Stuff             //对共享目录的说明文件,自己可以定义说明信息
path = /opt/mailstore              //用来指定共享的目录
; public = yes
writable = yes
guest ok = yes
directory mask = 0777
create mask = 0777
; printable = no
; write list = +staff

7、建立共享目录

[root@localhost /]# mkdir /opt/mailstore/

8、由于要设置匿名用户可以下载或上传共享文件,所以要给/opt/mailstore/目录授权为nobody权限

[root@localhost /]# chown -R nobody:nobody /opt/mailstore/

9、修改共享目录安全属性,由于Centos下默认samba不能访问任何文件夹,需要通过改变文件夹安全属性获得访问权限,否则无法访问(关键)

[root@localhost /]# chcon -R -t samba_share_t /opt/mailstore/

10、重启samba服务,完成所有配置

[root@localhost /]# service smb restart

11、测试smb.conf配置是否正确

[root@localhost /]# testparm

客户端访问:
Linux客户端访问

[root@localhost ~]# smbclient //192.168.0.20/public

Windows客户端访问

\\192.168.0.20

原文链接:CentOS 6.3下Samba服务器的安装与配置,转载请注明来源!

0