原文地址:https://www.cnblogs.com/snake553/p/8856729.html
查看一下系统版本:
rpm -q centos-release
centos-release-7-6.1810.2.el7.centos.x86_64
1.安装 httpd 服务
sudo yum install httpd
2.配置 httpd
Apache 的所有配置文件都位于 /etc/httpd/conf 和 /etc/httpd/conf.d,网站的数据默认位于 /var/www
查看监听端口
vi /etc/httpd/conf/httpd.conf
# 端口: Listen 80
3. 打开防火墙并打开端口 80
查看防火墙状态
systemctl status firewalld
Active: inactive (dead)
开启防火墙
systemctl start firewalld
Active: active (running)
查询TCP/UDP的80端口占用情况
sudo firewall-cmd --query-port=80/tcp
sudo firewall-cmd --query-port=80/udp
no
永久开放TCP/UDP的80端口
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --permanent --zone=public --add-port=80/udp
success
重启防火墙
sudo firewall-cmd --reload
success
4. 创建 index.html 文件
cd /var/www/html
vi index.html
#输入 helloworld 保存
将所有权设置为 apache.apache
chown apache.apache index.html
5.启动 Apache
sudo systemctl start httpd
6.测试
在浏览器中输入:http://你的ip地址
,显示如下
至此 http 基本服务搭建完成