1. 下载yumdownloader
yum install -y yum-utils
2. 下载samba
mkdir samba cd samba yumdownloader --resolve avahi-autoipd samba samba-client 或
yum install --downloadonly --downloaddir=./ samba
3. 安装samba
yum localinstall avahi-autoipd-0.6.31-17.el7.x86_64.rpm avahi-libs-0.6.31-17.el7.x86_64.rpm cups-libs-1.6.3-29.el7.x86_64.rpm krb5-libs-1.15.1-8.el7.x86_64.rpm libldb-1.1.29-1.el7.x86_64.rpm libsmbclient-4.6.2-11.el7_4.x86_64.rpm libtalloc-2.1.9-1.el7.x86_64.rpm libtdb-1.3.12-2.el7.x86_64.rpm libtevent-0.9.31-1.el7.x86_64.rpm libwbclient-4.6.2-11.el7_4.x86_64.rpm pytalloc-2.1.9-1.el7.x86_64.rpm samba-4.6.2-11.el7_4.x86_64.rpm samba-client-4.6.2-11.el7_4.x86_64.rpm samba-client-libs-4.6.2-11.el7_4.x86_64.rpm samba-common-4.6.2-11.el7_4.noarch.rpm samba-common-libs-4.6.2-11.el7_4.x86_64.rpm samba-common-tools-4.6.2-11.el7_4.x86_64.rpm samba-libs-4.6.2-11.el7_4.x86_64.rpm
或者
yum localinstall *
4. 配置samba
mkdir /home/share vim /etc/samba/smb.conf 在末尾添加 [share] comment = share path = /home/share writable = yes
保存并关闭smb.conf
设置登录用户名和密码
su root
smbpasswd -a root
5. 重启samba
service smb status
service smb restart
6. 访问共享文件夹
\192.168.1.100share
扩展:
在Centos7.2系统下已经安装了大部分依赖库,只需要安装samb即可
yum list installed | grep samba #查看samba依赖库版本
然后下载samba-4.2.3-10.el7.x86_64进行安装即可,建议下载地址:http://rpm.pbone.net/。
CentOS7.2 samba下载地址:http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/
http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-common-tools-4.2.3-10.el7.x86_64.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-libs-4.2.3-10.el7.x86_64.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-common-libs-4.2.3-10.el7.x86_64.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-common-4.2.3-10.el7.noarch.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-client-libs-4.2.3-10.el7.x86_64.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-client-4.2.3-10.el7.x86_64.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/samba-4.2.3-10.el7.x86_64.rpm http://ftp.scientificlinux.org/linux/scientific/7.2/x86_64/os/Packages/libsmbclient-4.2.3-10.el7.x86_64.rpm
建议关闭防火墙后使用:
systemctl stop firewalld.service
或者
firewall-cmd --query-port=445/tcp 查看445端口状态
firewall-cmd --permanent --add-port=445/tcp 开放445端口
systemctl restart firewalld.service 重启防火墙
提示没有写入权限:
#1 查看共享目录的所有者
#2 setenforce 0 //关闭SELinux