Ubuntu error with apache: (98)Address already in u

2019-01-30 15:48发布

I am getting this error when I try to start Apache in Ubuntu.

 (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
 no listening sockets available, shutting down
 Unable to open logs
 Action 'start' failed.

I have this in my ports.conf

NameVirtualHost *:80
Listen 80

This is my vhost file

<VirtualHost *:80>
          ServerAdmin example@example.com
          ServerName rails.server.com
          # ServerAlias
          DocumentRoot /var/www/sample_app/current/public
          ErrorLog /var/www/sample_app/error.log

          RailsEnv production
        <Directory "/var/www/sample_app/current/public">
          Options Indexes FollowSymLinks MultiViews
          Order allow,deny
          Allow from all
        </Directory>
</VirtualHost>

What am I missing?

14条回答
看我几分像从前
2楼-- · 2019-01-30 16:15

This is due to port 80 is shifted used by other service.

sudo killall httpd

Check any service is using 80 still

sudo netstat -tulpn| grep :80

and restart the server

sudo service httpd start

enter image description here

查看更多
Summer. ? 凉城
3楼-- · 2019-01-30 16:16

Make sure that you don't have the command Listen 80 in more than one place.

In my case, I was getting the same error and the reason was that this command was both in ports.conf and sites-enabled/000-default.

查看更多
时光不老,我们不散
4楼-- · 2019-01-30 16:20

In my case it was nginx ('cause I have it on my server).

sudo service nginx stop
sudo service apache2 start
查看更多
该账号已被封号
5楼-- · 2019-01-30 16:22

In all cases killing the process may not work, as the process using the port 80 will get restarted and doesn't allow to use the port. So what can be done is to change the port for apache, if that doesn't matter.

Two things are to be changed for that:

  1. Open /etc/apache2/ports.conf with any text editor and change the value of the entry Listen 80 to the desired port (e.g. Listen 8080).

  2. Change the entry for <virtualhost 80> to the same port number you gave in the /etc/apache2/ports.conf file in /etc/apache2/sites/enabled/000-default (e.g. <virtualhost 8080>).

查看更多
一纸荒年 Trace。
6楼-- · 2019-01-30 16:23
netstat -ltnp | grep :80

This would return the following:

tcp6 0 0 :::80 :::* LISTEN 1047/apache2

Then run the following command:

sudo kill -9 1047

(1047 - pid no)

(the pid that appears on your particular instance.)

Restart Apache.

sudo service apache2 restart

Reference to Ubuntu Forums.

查看更多
▲ chillily
7楼-- · 2019-01-30 16:24

Except the solution find process running on :80 and kill, then start again,

This error might have if you have multiple "Listen" entries in apache conf file or in any .conf files Included in apache conf file. Hope this helps to someone..!!

查看更多
登录 后发表回答