Install nginx on ubuntu10.04 today. After installation is complete, start nginx and run the following command:
The code is as follows: |
Copy code |
Sudo/etc/init. d/nginx start |
The error message is as follows:
Hankcs @ ubuntu :~ $ Sudo/etc/init. d/nginx start
[Sudo] password for hankcs:
* Starting nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 80 failed (98: Address already in use)
Nginx: [emerg] bind () to [:]: 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:
The code is as follows: |
Copy code |
Hankcs @ ubuntu :~ $ Netstat-ntpl Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name Tcp 0 0 127.0.0.1: 53 0.0.0.0: * LISTEN- Tcp 0 0 127.0.0.1: 631 0.0.0.0: * LISTEN- Hankcs @ ubuntu :~ $ Killall-9 nginx |
Nginx: no operation found
Nginx configuration file
The code is as follows: |
Copy code |
Hankcs @ ubuntu :~ $ Sudo gedit/etc/nginx/sites-available/default Modify this section: Listen 80; Listen [:]: 80 default_server; Is Listen 80; Listen [:]: 80 listen 6only = on default_server; |
Start nginx and solve it perfectly!
If you find the operation, we can perform the following operations:
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:
The code is as follows: |
Copy code |
Kill-9 3274 Kill-9 3547 Service nginx start Starting nginx: |
Add an 80 occupation solution
Cause: port 80 is occupied. Run the "lsof-I: 80" command to check which program occupies port 80. My result shows that port 80 is occupied by apache.
[Root @ localhost html] # lsof-I: 80
Command pid user fd type device size/OFF NODE NAME
Httpd 1203 root 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1217 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1218 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1219 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1220 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1221 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1222 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1223 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1224 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1285 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1830 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1871 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1872 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1873 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1874 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1875 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1876 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN)
Httpd 1877 apache 4u IPv6 8514 0t0 TCP *: http (LISTEN) solution: handle the problem according to your own situation, I stopped apache and uninstalled it directly (because apache is no longer used). I restarted nginx.