安裝 apache2 後,啓動總是錯誤
sunshine@gentoo /etc/apache2 $ sudo /etc/init.d/apache2 start
* Starting apache2 ...
apache2: apr_sockaddr_info_get() failed for gentoo
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
* start-stop-daemon: failed to start `/usr/sbin/apache2'
[ ok ]
用 strace 跟蹤也找不到問題
去看 apache2 的log
tail -f /var/log/apache2/error_log
[Sun Oct 30 20:29:34 2011] [alert] (EAI 3)Temporary failure in name resolution: mod_unique_id: unable to find IPv4 address of "gentoo"
Configuration Failed
google之,最後鎖定問題關鍵,gentoo 這個hostname找不到ip地址..
操蛋,怎麼也想不到這裏有問題
sunshine@gentoo /var/log/apache2 $ hostname
gentoo
hostname 果然是gentoo,當時配置的時候想要讓別人在網絡上知道我是用的gentoo,所以用的這個名字。
所以在 /etc/hosts 中加入 gentoo 別名對應的本機ip就ok了
sunshine@gentoo ~ $ cat /etc/hosts
127.0.0.1 gentoo localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 gentoo localhost localhost.localdomain localhost6 localhost6.localdomain6
tail -f /var/log/apache2/error_log
[Sun Oct 30 20:33:48 2011] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/1.0.0e configured -- resuming normal operations