良许Linux教程网 干货合集 自定义Apache Web首页内容实现方法

自定义Apache Web首页内容实现方法

如何自定义Apache Web首页内容?这个问题相当简单,编写index.html文件即可实现自定义内容,下面一起来看一下具体实现方法。

image-20220115213819662

1. 安装Apache

[root@localhost ~]# yum install -y httpd

2. 修改/etc/httpd/conf/httpd.conf配置文件

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
在 vim 中,快速定位到 第 95行
命令模式下 输入 :95
修改为以下形式。记得去掉 # 号

ServerName 192.168.XX.XX:80

: wq 保存退出

3. 启动web服务

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# netstat -ntl #确认80端口已启用
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp6 0 0 :::80 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN

4. 检查Apache Web服务是否正常

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
[root@localhost html]# iptables -F
[root@localhost html]# ifconfig
ens32: flags=4163 mtu 1500
inet 192.168.10.11 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::20c:29ff:feda:182e prefixlen 64 scopeid 0x20 ether 00:0c:29:da:18:2e txqueuelen 1000 (Ethernet)
RX packets 930 bytes 77097 (75.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 575 bytes 77429 (75.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 88 bytes 7484 (7.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 88 bytes 7484 (7.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

在浏览器输入192.168.10.11,出现以下界面,说明Apache Web服务正常。

自定义Apache Web服务的首页内容自定义Apache Web服务的首页内容

5. 自定义首页文件

[root@localhost html]# pwd
/var/www/html
[root@localhost html]# vim index.html

[root@localhost html]# systemctl restart httpd

在浏览器输入192.168.10.11,出现以下界面,说明自定义首页文件生效。

自定义Apache Web服务的首页内容自定义Apache Web服务的首页内容
自定义Apache Web服务的首页内容自定义Apache Web服务的首页内容

以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

img
本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部