samba

# yum install samba samba-client samba-swat

 安装samba完后会生成samba目录  -----> /etc/samba

[root@centos02 ~]# ls /etc/samba/
lmhosts  smb.conf  smbusers

 

vi /etc/samba/smb.conf

 

[global]
workgroup = WORKGROUP

 http://blog.csdn.net/xt_xiaotian/article/details/4216408

 hosts allow = 127. 192.168.1. 192.168.2. 127.

 允许的IP地址段,将自己的IP地址段加入即可(注意IP的最后一段没有,但后边有个点)

security = share  
 // 可以为如下几个(在不考虑安全的前提下,建议使用share)

         // share:用户不需要账户及密码即可登录samba服务器
         // user:由提供服务的samba服务器负责检查账户及密码(默认)
         // server:检查账户及密码的工作由另一台windows或samba服务器负责
         // domain:指定windows域控制服务器来验证用户的账户及密码)

 

[share]
    path = /mnt/share 
    public = yes

;   only guest = yes
    writable = yes
;   printable = no
    create mode = 0777

    directory mode = 0777

 

# /etc/init.d/smb restart

 

[root@centos02 ~]# /etc/init.d/smb restart
Shutting down SMB services:                                [  OK  ]
Starting SMB services:                                     [  OK  ]

 

# chmod 777 /mnt/share

 

重启机器时,smb服务并不会自动启动

现在让我们回到Windows

\\192.168.1.73

 结合apache 实现浏览共享里面的文件:

# vi /etc/httpd/conf/httpd.conf
#DocumentRoot "/var/www/html"
DocumentRoot "/home/test #与cmb 的share为同一目录 vi /etc/samba/smb.conf--->path = /home/test/share
<Directory "/home/test">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks  #这里Indexes控制是否打开目录浏览,如果要关闭目录浏览,使用Option -Indexes


#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

 出现了乱码:中文支持不太好

 ------------------------------------------

# useradd -s /sbin/nologin admin
[root@node02 ~]# smbpasswd -a admin
New SMB password:
Retype new SMB password:
Added user admin.

 

 SAMBA结合Apache实现直接浏览samba下的文件,以列表形式

[root@node02 conf]# pwd
/etc/httpd/conf
[root@node02 conf]# vi httpd.conf
#在httpd.conf结尾加上,下面这条语句
AddType text/css .css 

 

<Directory "/home/test">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks #你只需要将上面代码中的 Indexes 去掉,就可以禁止 Apache 显示该目录结构。用户就不会看到该目录下的文件和子目录列表了

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all
    Options Indexes FollowSymLinks
</Directory>

 

posted @ 2016-04-25 22:38  bass  阅读(344)  评论(0编辑  收藏  举报