centos7上搭建http服务器

原文地址: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 基本服务搭建完成

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值