
我在啟動 Apache 時收到此錯誤訊息。我使用的是 macOS Mojave 10.14.5。
AH00558:httpd:無法使用 Stevens-MacBook-Air.local 可靠地確定伺服器的完全限定網域名稱。全域設定“ServerName”指令以抑制此訊息httpd(pid 856)已經運行
我在文件中新增了名稱伺服器httpd.conf
,但仍然出現此錯誤訊息。
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
#ServerName localhost:8080
我錯過了什麼,這則訊息仍然出現?
答案1
我在 httpd.conf 檔案中新增了名稱伺服器,但仍然出現此錯誤訊息。
很遺憾地說,不,你沒有。這其實就是你所擁有的:
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
#ServerName localhost:8080
請注意上面的所有行#ServerName localhost:8080
是如何#
添加到它們前面的。這意味著它們被註解掉了。查看該設定檔;還有其他行被註解和註解掉。為了使您的設定生效,您需要像這樣取消註釋。
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80
ServerName localhost:8080
然後重新啟動 Apache,您應該能夠按http://localhost:8080
預期訪問該 Apache 伺服器。
答案2
將一行內容加入到 apache 配置的完全限定主機名稱:
LINE='ServerName www.example.com'
FILE='/etc/apache2/apache2.conf'
grep -qF -- "$LINE" "$FILE" || echo "$LINE" >> "$FILE"
service apache2 restart
如果您的伺服器沒有網域,請localhost
改用