Apache-2.2

如何在 FreeBSD 上為 apache22 軟體包配置主機名?

  • February 27, 2011

我正在 VM 上配置開發和測試 FreeBSD 機器。我安裝了apache22軟體包並重新啟動。但是守護程序沒有以這個錯誤啟動:

%apachectl start
httpd: apr_sockaddr_info_get() failed for test.box
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
%

我的主機名是test.box. 因為這是臨時測試盒,所以沒有真正的域名。但我使用 2 級名稱來避免長時間等待sshd啟動。

但是,我搜尋了網頁,並/etc/hosts像這樣修改了文件(我之前沒有接觸過這個文件):

# This is original configuration
#::1                    localhost localhost.my.domain
#127.0.0.1              localhost localhost.my.domain

# New configuration    
::1                     localhost test.box
127.0.0.1               localhost test.box
127.0.0.1               test.box test

現在 apache 失敗並顯示此錯誤消息:

%apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using test.box for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
%

我不知道現在需要什麼。請讓我知道此錯誤的原因和解決方案。

    • (編輯) - -

權限錯誤是由於遺漏sudo.

httpd: Could not reliably determine the server's fully qualified domain name, using test.box for ServerName

通常,這只是一個警告,而不是致命錯誤。可以通過將配置添加到apache2.conf文件中來解決。

ServerName yourserver.yourdomain.com

我可以看到有一個權限被拒絕錯誤。確保以超級使用者身份呼叫啟動腳本root。另外,確保沒有其他程序已經在監聽 apache 埠(預設 80)。

我找到了解決方案。/etc/hosts 文件配置錯誤。這是正確的配置。

# This is original configuration
#::1                    localhost localhost.my.domain
#127.0.0.1              localhost localhost.my.domain

::1                     localhost.test.box localhost
127.0.0.1               localhost.test.box localhost
127.0.0.1               test.box test

引用自:https://serverfault.com/questions/240768