Samba文件服务器安装配置


在准备安装之前你可以查看下自己的liunx的系统版本以及系统类型,以便准备相应的版本软件
 
1.查看内核版本详细信息,包括主机名称
 
1 # uname -a 
 
安装有两种方式:
 
1.rpm命令安装。 rpm -ivh 安装包
 
这种方式一般都是通过 mount 挂载安装包镜像
 
2.yum命令安装。我这里演示的就是这种方式
 
这种方式请确保虚拟机能和本机联网,能相互ping的通就OK。
 
一、环境准备:
 
CentOS 6.2版本(32位)
IP地址:192.168.153.66(虚拟机);
虚拟机:VMware-workstation-full-8.0.0-471780;
samba软件:samba-3.6.23-20.el6.i686;
 
工作组:WORKGROUP。//定义windows中显示出来的计算机名称
 
二、安装软件
 
1.执行如下命令安装samba:
 
1 # yum install samba samba-client samba-swat
 
2.检查samba是否安装成功:
 
1 # rpm -qa | grep samba
samba的安装目录一般在 /etc/samba
 
3.启动samba服务及状态检查:
 
# /etc/init.d/smb start
4.设置开机自启动,并查看是否设置成功:
 
--设置
 
# chkconfig –level 35 smb on
# chkconfig –level 35 nmb on
--查看
 
# chkconfig –list | grep smb
三、服务配置
 
Samba服务配置主要是指/etc/samba/smb.conf文件的配置。
 
我在这里只演示一种最简单的共享方式(不需要用户名、密码即可访问),至于其它的配置可以点击(更多方式)进行参考配置。
 
1.把配置文件重定向到一个文件,并且备份smb.conf的源文件
 
1 # grep -v "^[#;]" smb.conf | grep -v "^$" >> smb.conf.txt
2 # cp smb.conf smb.conf.copy
3 # mv smb.conf.txt smb.conf
2.修改samba服务器的主配置文件smb.conf
 
 1 [global]
 2 
 3         workgroup = WORKGROUP
 4         server string = Samba Server Version %v
 5         netbios name = VMQiheng
 6 
 7         # logs split per machine
 8         log file = /var/log/samba/log.%m
 9         # max 50KB per log file, then rotate
10         max log size = 50
11 
12         # max 50KB per log file, then rotate
13         max log size = 50
14 
15         security = share
16         passdb backend = tdbsam
17 
18         # the login script name depends on the machine name
19         # the login script name depends on the unix user used
20         # disables profiles support by specifing an empty path
21 
22         load printers = yes
23         cups options = raw
24         #obtain list of printers automatically on SystemV
25 
26 [homes]
27         comment = Home Directories
28         browseable = no
29         writable = yes
30 
31 [printers]
32         comment = All Printers
33         path = /var/spool/samba
34         browseable = no
35         guest ok = no
36         writable = no
37         printable = yes
38 
39 [beyond]
40         comment = Public share with beyond file
41         path = /share
42         public = yes
43         writable = yes

 

以上是我的samba服务器的conf设置,在配置文件里我添加了 [beyond] 这个节点,分享目录在liunx的根目录下的 share 文件夹
 
2.1.创建分享目录
 
# mkdir share
2.2.给分享目录授权为nobody权限
 
# chown -R nobody:nobody /share
3.重启smb服务:
 
1 # /etc/init.d/smb restart
2 # /etc/init.d/nmb restart
如果配置成功的话,就可以通过 liunx ip 访问到这个共享文件夹
[beyond] 就是我配置在Windows可以访问的共享目录。
 
可能出现的问题。
 
1.如果用windows上访问linux的共享目录,如,//192.168.100.88 ,根本找不到。
 
关闭linux的防火墙:
# service iptables stop。
 
2.可以看到共享文件夹,却没打不开文件夹(左图)或者在liunx中通过 # smbclient //127.0.0.1/beyond(右图)
这种情况,一般都是被SELinux阻挡了,你可以使用getenforce查看状态,如果是Enforcing,就使用setenforce 0关闭。
不过,我的liunx在下次开机的时候,windows上访问 liunx ip,还是需要出现上诉两个问题,我还得重新再设置一遍,好麻烦,不知道其熟悉liunx的朋友知不知道这是什么情况,欢迎留言指教。
 
到这里,samba服务器总算是安装成功了。对于我liunx菜鸟真的是一种折腾。希望这对你有帮助,帮助了你的解决问题的请不要吝惜点赞,我才更加有动力整理总结。

相关内容

    暂无相关文章