要自定義 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 流量。