on
it
road
.com
禁用 Apache 欢迎页面
方法 1:删除/重命名欢迎页面
- 为了禁用此页面,我们必须将文件 /etc/httpd/conf.d/welcome.conf 重命名为其他名称,或者如果我们不需要它,我们可以简单地将其删除。
# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_backup
- 确保使用以下命令重新启动 Apache(以 root 身份):
# systemctl restart httpd
方法 2 : 允许索引在 /etc/httpd/conf.d/welcome.conf
如果 DocumentRoot 没有索引,除非修改 /etc/httpd/conf.d/welcome.conf 以允许使用索引,否则将显示默认的 Apache 欢迎页面。
编辑 /etc/httpd/conf.d/welcome.conf 以允许索引。注释 /etc/httpd/conf.d/welcome.conf 中的 Options 行(添加 # 标记),如下所示:
# vi /etc/httpd/conf.d/welcome.conf <LocationMatch "^/+$"> # Options -Indexes ErrorDocument 403 /error/noindex.html </LocationMatch>
或者我们可以通过将 更改为 + 来启用索引
# vi /etc/httpd/conf.d/welcome.conf <LocationMatch "^/+$"> Options +Indexes ErrorDocument 403 /error/noindex.html </LocationMatch>
- 重新启动 Apache 服务 (httpd) 以使更改生效。
# systemctl restart httpd
问题
当我们安装Apache 2 时,当我们第一次打开服务器的URL IP 时,我们会看到如下所示的“欢迎页面”。
我们可能也无法在默认文档根目录“/var/www/html”中找到此页面。
我们如何禁用此页面并显示我们自己的页面?
检查确认
让我们在文档根目录中添加一个简单的 index.html 页面来验证我们是否禁用了欢迎页面并可以查看文档根目录中的页面。
# echo "<h1>This is a Test Page</h1>" > /var/www/html/index.html
打开浏览器并将其指向服务器 IP 地址。 http://服务器ip
解决方案
为了改变这种行为,检查是否有一个名为 /etc/httpd/conf.d/welcome.conf 的文件。
这是显示为欢迎页面的页面。
日期:2020-09-17 00:13:32 来源:oir作者:oir