2015年1月19日月曜日

Apache2 not starting

When trying to configure Virtual Hosts on Ubuntu 14.04.1, Apache2 did not start and got the error like following.

# service apache2 start
* Starting web server apache2
* (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
* The apache2 instance did not start within 20 seconds. Please read the log files to discover problems

Most blogs advise "Find the process which is using TCP Port 80.", but such process it not running.  Mmm....

root@ubuntu:/home/kotaro# netstat -ap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:mysql         *:*                     LISTEN      1159/mysqld    
tcp        0      0 *:ssh                   *:*                     LISTEN      1057/sshd      
tcp        0      0 172.16.45.169:ssh       172.16.45.1:49474       ESTABLISHED 1808/sshd: kotaro [
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1057/sshd      
udp        0      0 *:bootpc                *:*                                 901/dhclient   
udp        0      0 *:11004                 *:*                                 901/dhclient   
udp6       0      0 [::]:9859               [::]:*                              901/dhclient   

I got the problem in "/etc/apache2/sites-enabled/000-default.conf".

Listen 80

        ServerName www.abc.com
        ServerAdmin webmaster@abc.com
        DocumentRoot /var/www/html/abc

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

The line of "Listen 80" was not necessary.  It looks Apache2 tried to use TCP Port 80 twice (default behavior and another one caused by my configuration), and naturally failed in the second attempt.  I can understand I could not find any process using TCP Port 80 after apache2 gives up to start....

I was so careless because I simply followed the note in Apache 2.4 documentation without thinking anything.  It was an easy mistake which I stuck in for 1 hour.....
Note
The use of does not affect what addresses Apache httpd listens on. You may need to ensure that Apache httpd is listening on the correct addresses using Listen.
After removing "Listen 80" then, it worked....

1 件のコメント:

石橋 良 さんのコメント...

日本語でOK