Reputation: 453
I use a digital ocean droplet as my development environment. The droplet is DO's LAMP stack droplet on Ubuntu 14.04. I've got apache running to access my mysql database with phpmyadmin.
Recently phpmyadmin stopped working inexplicably. I checked it out and it looked like apache wasn't starting properly. I get the following error:
* Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.\
So it looks like port 80 is being taken up by another process. Someone suggested to me that I use netstat
to figure out which process it is. Sure enough sudo netstat -tapen | grep ":80"
revealed that there were some other processes listening on port 80:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 8849 920/nginx
tcp 0 0 104.131.29.69:8000 0.0.0.0:* LISTEN 1000 10361 1683/php5
tcp6 0 0 :::80 :::* LISTEN 0 8850 920/nginx
So I tried to kill the process as per this answer. When I did, running netstat
again yielded this
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 8849 921/nginx: worker p
tcp 0 0 104.131.29.69:8000 0.0.0.0:* LISTEN 1000 10361 1683/php5
tcp6 0 0 :::80 :::* LISTEN 0 8850 921/nginx: worker p
So the process seems to have just changed numbers but didn't die.
I also tried this answer but nothing changed.
I have no idea what this nginx process is--I don't remember having ever started an nginx process on my server and in case I don't know how it could have survived my restarting the server various times (which I also tried). Several people suggested using netstat to find out what's listening on the port but I'm not sure what to do now that I've found it. Also why is it surviving my restarting the server? I'm pretty sure apache, or the php server that you see up there would both have to be restarted when the server's turned off.
Thanks.
Upvotes: 1
Views: 5134
Reputation: 241
This command will show you which process is using port 80:
sudo lsof -i:80
Make sure to use "sudo".
Upvotes: 5