關閉 SELinux
A2.
# setsebool samba_export_all_ro on
# setsebool samba_export_all_rw on
# getsebool -a | grep samba
Reference :
HowTos/SetUpSamba - CentOS Wiki
# setsebool samba_export_all_ro on
# setsebool samba_export_all_rw on
# getsebool -a | grep samba
# echo 0 >/selinux/enforce
# sestatusSELinux status: enabled
SELinuxfs mount: /selinux
Current mode: permissive
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
// install
# yum install samba samba-client samba-common -y
// firewall
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
# /etc/init.d/iptables restart
// add samba user
# smbpasswd -a user1 // 須在系統上有相同的帳號
// set share directory
# vi /etc/samba/smb.conf
[global]
security = user
[share]
comment = Share Storage
path = /mnt/datadisk
browsable = yes
guest ok = yes
read only = no
valid users = user1 user2
// restart services
# /etc/init.d/smb restart
# yum install nfs* -y
# vi /etc/exports
/mnt/data 192.168.1.0/24(rw,sync,no_root_squash,no_all_squash)
# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
-A INPUT -m state --state NEW -m udp -p udp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# /etc/init.d/iptables restart
# /etc/init.d/rpcbind restart
# /etc/init.d/nfs restart
# yum install nfs* -y
# /etc/init.d/rpcbind restart
# /etc/init.d/nfs restart
# mount -t nfs 192.168.1.200:/mnt/data/ /nfs/shared/
# vi /etc/yum.repos.d/nginx.repo
# yum install nginx -y[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
# /etc/init.d/nginx restart
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5
# cd /var/lib/apt
# mv lists lists.old
# mkdir -p lists/partial
# apt-get update