
當我(重新)啟動 Apache 時,我不斷收到此警告。
* Restarting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
etc/hosts
這是我的文件的內容:
#127.0.0.1 hpdtp-ubuntu910
#testproject.localhost localhost.localdomain localhost
#127.0.1.1 hpdtp-ubuntu910
127.0.0.1 localhost
127.0.0.1 testproject.localhost
127.0.1.1 hpdtp-ubuntu910
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
/etc/apache2/sites-enabled/000-default
這是我的文件的內容:
<VirtualHost *:80>
ServerName testproject.localhost
DocumentRoot "/home/morpheous/work/websites/testproject/web"
DirectoryIndex index.php
<Directory "/home/morpheous/work/websites/testproject/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /lib/vendor/symfony/symfony-1.3.2/data/web/sf
<Directory "/lib/vendor/symfony/symfony-1.3.2/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
當我轉到 時http://testproject.localhost
,我得到一個空白頁。
誰能發現我做錯了什麼嗎?
答案1
預設情況下,Ubuntu 不會在 Apache 配置中指定 ServerName,因為它不知道伺服器的名稱是什麼。它會嘗試對您的 IP 位址進行反向查找,但不會傳回任何內容,因此它只需使用 IP 位址作為伺服器名稱。
若要修復它,請新增 ServerName 指令在任何虛擬主機之外- 例如/etc/apache2/httpd.conf
,或為您的主 IP 位址設定反向 DNS 回應 - 在本例中為 127.0.1.1
忽略它也完全沒問題。
答案2
這是一個快速修復:
echo ServerName $HOSTNAME > /etc/apache2/conf.d/fqdn
答案3
解決該警告的另一種方法是將完全限定的網域127.0.1.1
放在/etc/hosts
.它甚至不必是能夠實際解析 dns 伺服器上任何內容的 FQDN。
127.0.1.1 hpdtp-ubuntu910.lan hpdtp-ubuntu910
就可以做到這一點,同時保留任何不期望額外的程序的行為.lan
。順序很重要;應先指定具有更多層級的名稱,如本例中,.lan
位址位於另一個位址之前。
答案4
httpd.conf 中的設定ServerName
對我不起作用。我透過設定ServerName 127.0.0.1
來修復它/etc/apache2/conf.d/name
。
我正在運行 Ubuntu 12.10 Alpha3 並ServerName
在這兩個位置都進行了定義。