nginx启动报错:如下:

[root@slave nginx-1.8.0]# /usr/local/nginx/sbin/nginx 
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 could not bind()

字面意思就是80端口被占用,可以修改nginx默认端口不为80,也可以释放80端口;

首先查看80端口得情况:

[root@slave local]# netstat -lnp |grep 80
tcp        0      0 :::80                       :::*                        LISTEN      1511/httpd

有一个httpd进程占用,然后查看进程pid,直接杀死,如果这个服务不是正在使用!

[root@slave conf]# ps aux |grep http
root      1511  0.0  0.3  11472  3296 ?        Ss   05:09   0:00 /usr/sbin/httpd
apache    1517  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1518  0.0  0.2  11472  2172 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1519  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1520  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1521  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1522  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1523  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
apache    1524  0.0  0.2  11472  2144 ?        S    05:09   0:00 /usr/sbin/httpd
root      9257  0.0  0.0   4360   808 pts/0    S+   09:18   0:00 grep --color http

还是蛮多得,然后杀死进程:

[root@slave conf]# kill 1511
[root@slave conf]# netstat -lnp |grep 80  /80端口已经释放
[root@slave conf]#

然后重新启动nginx:

[root@slave conf]# /usr/local/nginx/sbin/nginx 
[root@slave conf]# ps aux |grep nginx
root      9272  0.0  0.0   5400   564 ?        Ss   09:22   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    9273  0.0  0.0   5600   912 ?        S    09:22   0:00 nginx: worker process      
root      9276  0.0  0.0   4356   740 pts/0    S+   09:22   0:00 grep --color nginx
[root@slave conf]#

还有一篇日志中介绍这样得,没试过,附上地址http://www.hankcs.com/appos/linux/fix-nginx-bind-err.html