CentOS配置SAMBA实现windows共享linux文件

来源:岁月联盟 编辑:exp 时间:2011-12-06

 

为了方便部署后的应用升级,通过配置linux的samba实现windows共享linux的应用程序目录,简化和加快日后的应用升级和部署工作。

[root@tomcat ~]# uname -a

Linux tomcat 2.6.9-89.ELsmp #1 SMP Mon Jun 22 12:32:43 EDT 2009 i686 i686 i386 GNU/Linux

[root@tomcat ~]# cat /etc/issue

CentOS release 4.8 (Final)

Kernel /r on an /m

 

[root@tomcat ~]# rpm -qa | grep sam

samba-3.0.33-0.17.el4

samba-client-3.0.33-0.17.el4

system-config-samba-1.2.21-1.el4.1

samba-common-3.0.33-0.17.el4

[root@tomcat ~]# find / -name smb.conf

/etc/samba/smb.conf

 

我们要修改的配置文件就是/etc/samba/smb.conf,增加如下几行:

[tomcat] ; 随便起个你想要的名字

path = /opt/tomcat ; 共享的目录

valid users = tomcat ; 共享登陆用户

public = no ;

writable = yes ; 是否允许写入

printable = no ;

create mask = 0765   ; 新建文件目录的默认权限

www.2cto.com

设置完成后可以使用testparm进行配置文件的验证

[root@tomcat ~]# testparm

Load smb config files from /etc/samba/smb.conf

Processing section "[printers]"

Processing section "[tomcat]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

 

[global]

        workgroup = MYGROUP

        server string = Samba Server Version %v

        passdb backend = tdbsam

        idmap uid = 16777216-33554431

        idmap gid = 16777216-33554431

        cups options = raw

。。。。。

。。。。。

 

设置访问用户和密码

[root@tomcat ~]#smbpasswd tomcat

输入你要设置的密码即可,注意这个用户密码是在win访问的时候使用的,用户可以是已经存在的,像我这里使用的就是应用的用户。

 

关闭防火墙

[root@tomcat ~]# service iptables stop

禁用防火墙

[root@tomcat ~]# chkconfig iptables off

 

手工启动SMB

[root@tomcat ~]# service smb start

启动SMB 服务:

启动NMB 服务:

配置SMB自启动

[root@tomcat ~]# chkconfig smb on

OK,可以在win客户端输入//ip进行访问linux提供的共享目录了。

-The End-

 

摘自 Gtlions