> 文章列表 > CentOS快速部署Apache服务-配置防火墙

CentOS快速部署Apache服务-配置防火墙

CentOS快速部署Apache服务-配置防火墙

目录

配置Apache服务

配置防火墙


配置Apache服务

  1. 将服务器当前的用户切换至root用户,便于后续配置应用。
    sudo su root
  2. 运行以下命令,安装Apache服务。
    yum install -y httpd
  3. 依次运行以下命令,启动Apache服务,并将服务设置为开机自启动。
    systemctl start httpd
  4. 启动Apache服务:
    systemctl start httpd
  5. 将Apache服务设置为开机自启动:
    systemctl enable httpd
  6. 运行以下命令,查看Apache服务的运行状态。
    systemctl status httpd

配置防火墙

  1. 查看80端口占用情况
    netstat -an|grep :80
  2. 检查Apache是否已经安装了开机自启

    systemctl list-unit-files | grep httpd
  3. 查看防火墙状态

    systemctl status firewalld
  4. 查看防火墙端口开放情况

    firewall-cmd --list-ports
  5. 防火墙开启centos7的80端口

    firewall-cmd --zone=public --add-port=80/tcp --permanent
  6. 重启防火墙

    firewall-cmd --reload