During LNMP, The nginx service was started and cannot be enabled. As a result, the web page cannot be opened. The following error message is displayed when starting the service:
Starting nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)
Nginx: [emerg] still cocould not bind ()
Problem description: The address is already in use. The nginx service may be stuck, causing port occupation. This error occurs.
Solution: first, use lsof: 80 to check which program occupies port 80. Lsof returns the following results:
Command pid user fd type device size/OFF NODE NAME
Nginx 3274 root 6u IPv4 10664 0t0 TCP *: http (LISTEN)
Nginx 3547 nginx 6u IPv4 10664 0t0 TCP *: http (LISTEN)
It was found that it was an nginx program, so we dropped the nginx service k and restarted the service .. The command is as follows:
Kill-9 3274
Kill-9 3547
Service nginx start
Starting nginx: [OK]
OK. The service is started successfully !~~