zoukankan      html  css  js  c++  java
  • CentOS7使用httpd apache 和firewalld打开关闭防火墙与端口

    Centos7 使用systemctl 工具操作命令

    systemctl 是Centos7的服务管理工具中的主要工具 ,它融合之前service和chkconfig的功能于一体

    一、httpd的设置

    第一 、 httpd 服务的启动 停止 重启

    启动 : systemctl start httpd.service 

    停止:    systemctl stop httpd.service 

    重启:     systemctl restart httpd.service

    查看httpd 的状态

    systemctl status httpd.service

    第二、将httpd 服务设置开机启动

    设置为开机启动 :  systemctl enable httpd.service

    设置开机不启动:   systemctl disable httpd.service 

    二、防火墙设置

    firewalld 打开关闭防火墙端口

        1.启动:  systemctl start firewalld

        2.查看状态: systemctl status firewalld

        3.停止: systemctl stop firewalld

        4.禁用:systemctl disable firewalld

    使用systemctl命令

    启动一个服务:     systemctl start firewalld.service 

    停止一个服务:     systemctl stop firewalld.service

    重启一个服务:    systemctl restart firewalld.service 

    查看一个服务的状态 :    systemctl status firewalld.service

    在开机时启动一个服务:    systemctl enable firewalld.service 

    在开机时禁用一个服务:    systemctl disable firewalld.service

    查看已经启动的服务列表法:  systemctl list-unit-files|grep enabled

    查看启动失败的服务: systemctl --failed

    配置  firewall-cmd 

    查看版本:firewall-cmd --version

    查看帮助:  firewall-cmd --help

    查看状态:  firewall-cmd --state

    查看所有打开的端口:  firewall-cmd --zone=public --list-ports

    更新防火墙规则: firewall-cmd --reload

    查看区域信息: firewall-cmd --get-active-zones

    查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
    拒绝所有包:firewall-cmd --panic-on
    取消拒绝状态: firewall-cmd --panic-off
    查看是否拒绝: firewall-cmd --query-panic

    开启一个端口

    firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent 这个参数是永久生效,如果不设置这个参数,默认重启后就失效)

    重新载入,使设置剩下

    firewall-cmd --reload

    查看

    firewall-cmd --zone=public --query-port=80/tcp

    删除

    firewall-cmd --zone=public --remove-port=80/tcp --permanent

  • 相关阅读:
    POJ2104&&HDU2665(静态区间第K小)
    HDU4763
    js 获取视频的第一帧
    hadoop 集群配置
    redis_cli 批量删除
    vmware centos 7 更新vmware-tools
    php计算两个整数的最大公约数常用算法小结
    centOS 7 配置NAT模式
    centOS配置NAT模式
    show table status 获取表的信息
  • 原文地址:https://www.cnblogs.com/kangxinxin/p/9615599.html
Copyright © 2011-2022 走看看