使用 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 浏览网页

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM