如题最近在学习Linux下各种服务器架设,在架设SAMBA服务器时遇到了问题,前后查资料好几天才解决,现在和广大网友分享一下小弟这两天的总结,如果有哪里说的不对望朋友们见谅,请指出我会及时修改的,下面言归正传.....                    (本文需要有一定的Linux基础)

 

首先我用的虚拟机是  :VMware® Workstation 版本是:8.0.1 build-528992

 

                 主机操作系统为:  Windows XP Professional 5.1.2600, Service Pack 3

 

                 在虚拟机上安装的是Centos 6.3 (Final)

 

                 内核为:2.6.32-279.5.2.el6.i686

 

(1). 下面是虚拟机上安装samba服务器端方法:(如果已经安装可略过此步骤)

                1). [root@www ~]# cat /etc/sysconfig/i18n

                                   LANG="zh_CN.UTF-8" <==确实是出现了 utf8 喔!

                      [root@www ~]#   yum install samba*

                         输入y,确定安装

                      [root@www samba]# cp smb.conf smb.conf.raw <==先备份再说!

                      [root@www samba]# vim smb.conf

                           [global]

                            # 与主机名有关的设定信息

                           workgroup= WORKGROUP

                           netbios name = smbserver

                           server string = This is Yu's samba server

                           unix charset= utf8

                           display charset = utf8

                           dos charset= gb2312

 

                           security = share

                           load printers= no

#

先取消 [homes], [printers] 的项目,然后针对 /tmp 的设定,可浏览

且可写入喔

[temp]                                                              <==分享资源名称

comment

= Temporary file space                            <==简单的解释此资源

path

= /tmp                                                        <==实际 Linux 分享的目录

writable

= yes                                                        <==是否可写入?在此例为

是的

browseable = yes                                      <==能不能被浏览到资源名称

guest ok

= yes                                                          <==单纯分享时,让用户随意

登入的设定值

 

2).用 testparm 查阅 smb.conf 的语法设定正确性

           [root@www ~]# testparm

 

3).重启服务端

[root@www ~]# /etc/init.d/smb restart 

[root@www ~]# /etc/init.d/nmb restart

chkconfig smb on

chkconfig nmb on

[root@www ~]# smbclient -L //127.0.0.1

Enter root's password: <==因为不需要密码,因此这里单击 [Enter] 吧!

[root@www ~]# mount -t cifs //127.0.0.1/temp /mnt    <==挂载到/mnt目录下

Password: <==因为没有密码,所以这里还是按 Enter 即可

[root@www ~]# df

[root@www ~]# cd /mnt

[root@www mnt]# ll <==以上这两个动作要进行!才会知道有没有权限的问题!

[root@www mnt]# touch zzz

[root@www mnt]# ll zzz /tmp/zzz

-rw-r--r--. 1 nobody nobody 0 Jul 29 13:08 /tmp/zzz

-rw-r--r--. 1 nobody nobody 0 Jul 29 13:08 zzz

# 注意喔!你进入 /mnt 身份会被压缩成为 nobody 呢!不再是 root 啊!

 

[root@www mnt]# iptables -F                                    命令把防火墙关掉。

[root@www mnt]# setenforce 0                                 命令把selinux关掉。

以下为永久关闭iptables和SELinux方法(慎用)

/etc/rc.d/init.d/iptables stop  

关闭SELinux的方法:

  修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。

  如果不想重启系统,使用命令setenforce 0

注:

setenforce 1 设置SELinux 成为enforcing模式

setenforce 0 设置SELinux 成为permissive模式 

  在lilo或者grub的启动参数中增加:selinux=0,也可以关闭selinux

 

#---------------------------------------------------------------

查看selinux状态:

/usr/bin/setstatus -v 

如下:

SELinux status:                 enabled

SELinuxfs mount:                /selinux

Current mode:                   permissive

Mode from config file:          enforcing

Policy version:                 21

Policy from config file:        targeted 

  

  getenforce/setenforce查看和设置SELinux的当前工作模式。

 

(2).下面是windows端配置问题:将虚拟机的网络设置成桥接,主要是让虚拟机网络和主机网络在一个网段

 

选择网卡属性,

安装

Microsoft网络客户端

VMware Bridge Protocol

Microsoft 网络的文件盒打印机共享

Microsoft TCP/IP 版本6

 开启windows服务:    

WORKSTATION服务

SERVER 服务

 Computer Browser服务

(3).  在windows下,点击"开始"->"运行"->输入"\\192.168.0.100"再点击确定,(上面的192.168.0.100为虚拟机的IP地址)

到此就能在windows端访问Linux SAMBA服务了

           时间仓促有时间再整理布局,如有问题欢迎大家和我讨论

                                                                 

 

 

 

                                                       本文为会飞的鱼原创,转载请注明,谢谢