centos7搭建完nginx后禁用firewall防火墙和selinux

来源:互联网 发布:jquery.checktree.js 编辑:程序博客网 时间:2024/06/05 06:01

禁用firewall防火墙

  1. firewall-cmd –state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
  2. systemctl stop firewalld.service #停止firewall
  3. systemctl disable firewalld.service #禁止firewall开机启动

启用iptables防火墙

  1. 安装iptables服务,yum -y install iptables-services
  2. 编辑iptables防火墙配置文件,开启80端口的访问权限,在
    -A INPUT -p tcp -m state --state NEW -m tcp--dport 22 -j ACCEPT行的上面或者下面添加-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
  3. systemctl restart iptables.service #最后重启防火墙使配置生效
  4. systemctl enable iptables.service #设置防火墙开机启动

禁用selinux

  1. 查看状态
    [root@centos7 nginx]# getenforce
    Enforcing
  2. 临时关闭 setenforce 0
  3. 临时开启 setenforce 1
  4. 永久关闭 vi /etc/selinux/config 修改SELINUX=disabled
  5. 重启系统
  6. 再次查看状态 sestatus或者getenforce