要自定义 CentOS 上 Apache2 的欢迎页,你需要编辑 Apache 的配置文件。以下是详细步骤:
打开终端。
使用文本编辑器(如 vim、nano 等)打开 Apache 配置文件。在这个例子中,我们将使用 vim 编辑器。输入以下命令:
sudo vim /etc/httpd/conf/httpd.conf
DirectoryIndex index.html index.php index.cgi index.pl index.xhtml index.htm
DirectoryIndex my-welcome-page.html index.html index.php index.cgi index.pl index.xhtml index.htm
保存并关闭配置文件。在 vim 编辑器中,按 “Esc” 键,然后输入 “:wq” 并按 “Enter” 键。
重启 Apache 服务以使更改生效。输入以下命令:
sudo systemctl restart httpd
现在,当你访问你的 CentOS 服务器的 IP 地址或域名时,你应该看到你的自定义欢迎页。如果你遇到任何问题,请确保检查防火墙设置以允许 HTTP 流量。