一、配置本地yum源
[root@centos7~]# cd /etc/yum.repos.d
[root@centos7 yum.repos.d]# mkdir bak
[root@centos7 yum.repos.d]# mv *.repo bak/
[root@centos7 yum.repos.d]# vim centos.repo
在centos.repo文件里添加内容为:
[source]
name=centos7-samba4
baseurl=file:///mnt
enabled=1
gpgcheck=0
二、挂在镜像文件
//挂载镜像文件
[root@centos7 ~]# mount /dev/cdrom /mnt/
//查看是否挂载成功
[root@centos7 ~]# df
[root@centos7 ~]# yum clean all
[root@centos7 ~]# yum repolist
三、安装samba
[root@centos7 ~]# yum -y install samba
//设置开机自启
[root@centos7 ~]# systemctl enable smb
[root@centos7 ~]# systemctl enable nmb
[root@centos7 ~]# systemctl is-enabled smb nmb
//查看监听的端口号
[root@centos7 ~]# netstat -anlpt | grep smb
[root@centos7 ~]# netstat -anlpu | grep nmb
//防火墙放行
[root@centos7 ~]# firewall-cmd --permanent --add-service=samba
四、创建共享文件夹
[root@centos7 ~]# mkdir /common
[root@centos7 ~]# smbpasswd -a 用户名
回车后输入密码
[root@centos7 ~]# pdbedit -L
//修改配置文件
[root@centos7 ~]# vim /etc/samba/smb.conf
//添加如下内容
[common]
comment = ziliao
path = /common
allow hosts = 192.168.99.0/24
user = 用户名
writable = yes
//语法检测
[root@centos7 ~]# testparm
//设置权限
[root@centos7 ~]# ll -d /common/
[root@centos7 ~]# chown -R 777 /common/
五、在windows下
win+r
输入\\192.168.99.66\common
有如下问题:
解决方法:
//在windows下执行net use * /del /y
C:\Users\666> net use * /del /y
六、解决windows无法访问的问题
在linux下:
[root@centos7 ~]# cd /etc/selinux/
[root@centos7 ~]# vim config
将SELINUX=enforcing 改为 SELINUX=disabled
最后重启linux。