使用 apache 搭建 web 服务器

部署环境如下:

系统:CentOS7.6

IP:192.168.121.105

Server version: 2.4.6

1.安装 apache,并设置 apache 服务启动和下次开机启动

[root@centos7 ~]# yum -y install httpd

[root@centos7 ~]# systemctl enable httpd --now

2.安装成功后切换目录,编辑 index.html 文件

[root@centos7 ~]# cd /var/www/html/

[root@centos7 html]# vim index.html

3.重启 apache 服务,关闭防火墙

[root@centos7 ~]# systemctl restart httpd

[root@centos7 ~]# systemctl stop firewalld

[root@centos7 ~]# systemctl disable firewalld

或者在不关闭防火墙的前提下放行 apache 服务和 80 端口( --per 为 --permanent )

[root@centos-server ~]# firewall-cmd --add-service=http

[root@centos-server ~]# firewall-cmd --add-service=http --per

[root@centos-server ~]# firewall-cmd --add-port=80/tcp

[root@centos-server ~]# firewall-cmd --add-port=80/tcp --per

4.查看 apache 状态和 80 端口是否被占用

[root@centos7 ~]# ps -ef | grep httpd

[root@centos7 ~]# ss -tunlp | grep 80

5.使用 IP 浏览网页

 

posted @ 2021-12-02 16:10  demoduan  阅读(1123)  评论(0编辑  收藏  举报