https://blog.youkuaiyun.com/weixin_41661222/article/details/80621372
#判断机器是否安装httpd
rpm -qa | grep httpd
#没有安装,安装一下
1.安装
yum –y install httpd
2.配置文件
/etc/httpd/conf/httpd.conf
监听端口默认80
#
#Listen 12.34.56.78:80
Listen 80
HTML文件位置
#
DocumentRoot "/var/www/html"
#
3.查看端口占用情况
firewall-cmd --query-port=80/tcp
firewall-cmd --query-port=80/udp
若返回no 则表示80端口未开启
永久开放80端口:
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=80/udp
重启防火墙:
firewall-cmd --reload
4.创建html文件
在/var/www/html中创建index.html内容为Hello World!
修改index.html的所有者和所属组为apache:
chown apache.apache index.html
5.启动服务
systemctl start httpd
设置开机自启:
systemctl enable httpd
重启服务:
systemctl restart httpd
6.访问http服务器
curl 172.17.24.170:80
在浏览器中访问
7.问题解决
错误信息:
Forbidden
You don't have permission to access / on this server.
Additionally, a 404 Not Found error was encountered while trying to use anErrorDocument to handle the request.
解决:
<Directory/>
AllowOverride none
Require all denied
</Directory>
修改为Require all granted

该博客详细介绍了在CentOS系统上安装和配置HTTPD服务器的步骤,包括使用`yum`安装httpd,配置监听端口,设置HTML文件路径,检查并开放防火墙端口,创建并设置权限的HTML文件,启动和设置httpd服务开机启动,以及解决访问权限问题。通过这些步骤,可以成功搭建并访问一个简单的HTTP服务器。
1649

被折叠的 条评论
为什么被折叠?



