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

2011.12.5CentOS配置SAMBA实现windows共享linux文件
为了方便部署后的应用升级,通过配置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   ; 新建文件目录的默认权限

设置完成后可以使用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提供的共享目录了。


2012.2.23更新 编译安装
0. download source package
1. tar zxvf samba-3.6.3.tar.gz
2. cd samba-3.6.3/source3
3. ./configure --prefix=/usr/local/samba
4. make
5. make install
6. make installbin
7. make installman # ./configure;make;make install;make installbin;make installman
8. make revert # Note that if you are upgrading from a previous version of Samba the old versions of the binaries will be renamed with an “.old” extension.
9. cp /root/samba-3.6.3/packaging/RHEL/setup/smb.conf /usr/local/samba/lib/smb.conf
10. link files
ln -s /usr/local/samba/lib/libtalloc.so.1  /usr/lib/libtalloc.so.1
ln -s /usr/local/samba/lib/libtdb.so.1  /usr/lib/libtdb.so.1
ln -s /usr/local/samba/lib/libwbclient.so.0  /usr/lib/libwbclient.so.0
ln -s /usr/local/samba/lib/libtalloc.so.2  /usr/lib/libtalloc.so.2
11. config services
check the /etc/services file,make sure include
netbios-ssn     139/tcp
netbios-ns    137/udp
12. Starting smbd as a Daemon
/usr/local/samba/sbin/smbd -D
/usr/local/samba/sbin/winbindd -D
/usr/local/samba/sbin/nmbd -D
13. config start smbd with system up
vi /etc/rc.d/rc.local,add follow lines:
/usr/local/samba/sbin/smbd -D
/usr/local/samba/sbin/winbindd -D
/usr/local/samba/sbin/nmbd -D
14. add user
[root@localhost bin]# /usr/local/samba/bin/smbpasswd -a samuser
New SMB password:
Retype new SMB password:
Added user samuser.
15. config the share dir
vi /usr/local/samba/lib/smb.conf
16. check config
/usr/local/samba/bin/testparm

-The End-
       

你可能感兴趣的:(tomcat,linux,windows,centos,service)