nginx 启动问题

2018-03-27 15:24:42 +08:00
 caixuanxu

nginx: [emerg] bind() to 0.0.0.0:38022 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:38022 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:38022 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:38022 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:38022 failed (48: Address already in use) nginx: [emerg] still could not bind()

这个怎么解决我换了几个接口也是一样的

1848 次点击
所在节点    问与答
22 条回复
lizhimiao
2018-03-27 15:33:23 +08:00
把配置文件贴出来看看.
hadoop
2018-03-27 15:34:26 +08:00
sudo lsof -i :38022 看下端口被谁占用了呗
caixuanxu
2018-03-27 15:35:46 +08:00
@hadoop 就是 nginx 本身
caixuanxu
2018-03-27 15:35:55 +08:00
@lizhimiao
#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 38022;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location /a {
root html;
index index.html index.htm;
proxy_pass http://localhost:28080;
}
#location /apis {
#rewrite ^.+apis/?(.*)$ /$1 break;
#include uwsgi_params;
#proxy_pass http://localhost:28080;
#}
#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}
caixuanxu
2018-03-27 15:36:32 +08:00
@lizhimiao 我在做跨域的 一直失败
ik
2018-03-27 15:38:42 +08:00
这是用的 restart 吧? killall nginx 再启动呢?
caixuanxu
2018-03-27 15:40:01 +08:00
@ik 一样的 有 QQ 吗 加个聊
加完后我会把留言删了
Lax
2018-03-27 15:43:36 +08:00
@caixuanxu lsof -i :38022 结果里还有 socket 状态,也看一下。有可能是还没有回收完成
lizhimiao
2018-03-27 15:45:10 +08:00
include servers/*;

这个目录下有配置文件吗?
caixuanxu
2018-03-27 15:45:19 +08:00
@Lax 关进程没有关系 就算 K 掉 还是会起来
caixuanxu
2018-03-27 15:45:35 +08:00
@lizhimiao 没有
ik
2018-03-27 15:55:24 +08:00
企鹅: MTA1NDc1Nzk=
渣渣一个,不一定能解决哈....

看 #10 的回复, 我觉得你应该把 #8 这个问题搞明白, nginx 有守护进程?
caixuanxu
2018-03-27 15:58:32 +08:00
@ik 有解决的办法吗
menghuan
2018-03-27 15:58:55 +08:00
你的 nginx 启动脚本有问题吧 重启时候没有杀死之前的进程
caixuanxu
2018-03-27 16:00:20 +08:00
@menghuan 我重启电脑 就不存在之前的进程了 可是还是同样的错
ik
2018-03-27 16:04:36 +08:00
@caixuanxu
```
1. ps 命令 先记下 nginx 主进程的 PID
2. killall nginx
3. 再 ps 看下是否有 nginx 主进程 PID 是否一致, 要是一致说明没有 kill 掉, 要是不一样, 那可能是有守护进程已经重启了, 可以试试新配置是否生效
```
caixuanxu
2018-03-27 16:08:17 +08:00
@ik 这些我都做过了
ik
2018-03-27 16:11:15 +08:00
@caixuanxu 目前也只能想到这样了, 你做过了。。。那么结论呢?
ik
2018-03-27 16:11:51 +08:00
@caixuanxu 这些操作的结果。。。
caixuanxu
2018-03-27 16:15:55 +08:00
@ik 配置的问题 杀进程肯定是不对的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/441815

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX