使用 apache 搭建 web 服务器

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

yum -y install httpd

systemctl enable httpd --now

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

cd /var/www/html/

vim index.html

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

systemctl restart httpd

systemctl stop firewalld

systemctl disable firewalld

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

firewall-cmd --add-service=http

firewall-cmd --add-service=http --per

firewall-cmd --add-port=80/tcp

firewall-cmd --add-port=80/tcp --per

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

ps aux | grep httpd

ss -tunlp | grep 80

5.使用 IP 浏览网页(下图拷贝了 jd 的门户网页文件)

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