RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1360447
Accepted
Dmitry
Dmitry
Asked:2022-05-13 18:44:29 +0000 UTC2022-05-13 18:44:29 +0000 UTC 2022-05-13 18:44:29 +0000 UTC

使用 Nginx 的意外结果

  • 772

服务器上有两个portal,使用Nginx空间中的Host-name划分。SSL 是使用 certbot 组织的。

把证书整理好,拿掉两个证书后(和portal的工作无关,早就过期了),Nginx服务器崩溃了。systemctl status nginx.service最有趣的事情

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2021-12-13 10:48:55 CET; 35min ago
       Docs: man:nginx(8)

错误:

des. 13 10:48:55 u nginx[248435]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
des. 13 10:48:55 u nginx[248435]: nginx: [emerg] still could not bind()
des. 13 10:48:55 u systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
des. 13 10:48:55 u systemd[1]: nginx.service: Failed with result 'exit-code'.
des. 13 10:48:55 u systemd[1]: Failed to start A high performance web server and a reverse proxy server.

令人惊讶的是,两个门户仍然可用(我马上说数据没有被缓存)。也就是说,从外部看,一切正常。

我检查了什么:

  1. ps -e,找到了 pid ,nginx这就是那里:三个进程,看起来像这样
● snap.certbot.certbot.***********.scope
     Loaded: loaded (/run/systemd/transient/snap.certbot.certbot.***********.scope; transien>
  Transient: yes
     Active: active (running) since Mon 2021-12-13 09:39:30 CET; 1h 35min ago
  1. 我试图杀死与 相关的进程nginx,但它们再次上升(我systemd/system/nginx.service删除了自动重新加载并通过 daemon-reload 重新启动,它没有帮助)
  2. 我试图杀死端口 80 上的进程,但它们又上升了

谁知道问题的根源以及在哪里挖掘以使其nginx“按应有的方式”工作?或者你能澄清我做错了什么吗

UPD

添加配置检查nginx

~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

检查端口表明 nginx 正在使用它们

~$ sudo lsof -i -P -n | grep LISTEN
nginx     245336        www-data    6u  IPv4 3142018      0t0  TCP *:80 (LISTEN)
nginx     245336        www-data    7u  IPv6 3142019      0t0  TCP *:80 (LISTEN)
nginx     245336        www-data    8u  IPv6 3142020      0t0  TCP *:443 (LISTEN)
nginx     245336        www-data    9u  IPv4 3142021      0t0  TCP *:443 (LISTEN)
nginx     245337        www-data    6u  IPv4 3142018      0t0  TCP *:80 (LISTEN)
nginx     245337        www-data    7u  IPv6 3142019      0t0  TCP *:80 (LISTEN)
nginx     245337        www-data    8u  IPv6 3142020      0t0  TCP *:443 (LISTEN)
nginx     245337        www-data    9u  IPv4 3142021      0t0  TCP *:443 (LISTEN)
nginx     245338        www-data    6u  IPv4 3142018      0t0  TCP *:80 (LISTEN)
nginx     245338        www-data    7u  IPv6 3142019      0t0  TCP *:80 (LISTEN)
nginx     245338        www-data    8u  IPv6 3142020      0t0  TCP *:443 (LISTEN)
nginx     245338        www-data    9u  IPv4 3142021      0t0  TCP *:443 (LISTEN)
~$ sudo ps -ax | grep nginx
 245336 ?        S      0:00 nginx: worker process
 245337 ?        S      0:00 nginx: worker process
 245338 ?        S      0:00 nginx: worker process
 250704 pts/7    S+     0:00 grep --color=auto nginx

linux
  • 3 3 个回答
  • 10 Views

3 个回答

  • Voted
  1. Aleksey Vaganov
    2022-05-13T19:57:07Z2022-05-13T19:57:07Z

    要检查配置,该命令将有所帮助nginx -t,并且为了重新读取配置nginx -s reload

    • 1
  2. stck
    2022-05-16T17:29:07Z2022-05-16T17:29:07Z

    看起来这一切都与 certbot 服务有关。在 中查找,/etc/systemd/system/很可能你会在那里找到定义,尝试停止(另外,可能有 cron 计时器,检查/etc/cron.d/)。从文档中的信息来看,Nginx 使用的challengehttp-01刚好占用了80 端口。

    • 1
  3. Best Answer
    DiD
    2022-05-19T02:23:39Z2022-05-19T02:23:39Z

    Nginx 进程不仅由 systemd 管理,还由 init.d 脚本管理:

    sudo /etc/init.d/nginx start
    sudo /etc/init.d/nginx stop
    sudo /etc/init.d/nginx restart
    

    您可以停止 nginx 进程

     kill $(ps aux | grep '[n]ginx' | awk '{print $2}')
    

    或更简单

     killall nginx
    

    如果将某些内容写入日志,您可以过滤它们:

    • 通过进程命令头:

      journalctl -f _COMM=nginx
      
    • 按 PID:

      journalctl _PID=1071
      
    • 按用户:

      journalctl _UID=1001
      

    您可以分别显示日志中存在的进程的所有 PID 和 UID

     journalctl -F _PID
     journalctl -F _UID
    
    • 1

相关问题

  • 如果 fuser -k number/tcp 没有帮助,如何在 Debian 中释放端口?

  • Ubuntu。startx 不起作用。黑屏

  • --syn 在 iptables 中有什么作用?

  • 为什么需要iso格式?

  • C程序中没有密码的sudo

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    表格填充不起作用

    • 2 个回答
  • Marko Smith

    提示 50/50,有两个,其中一个是正确的

    • 1 个回答
  • Marko Smith

    在 PyQt5 中停止进程

    • 1 个回答
  • Marko Smith

    我的脚本不工作

    • 1 个回答
  • Marko Smith

    在文本文件中写入和读取列表

    • 2 个回答
  • Marko Smith

    如何像屏幕截图中那样并排排列这些块?

    • 1 个回答
  • Marko Smith

    确定文本文件中每一行的字符数

    • 2 个回答
  • Marko Smith

    将接口对象传递给 JAVA 构造函数

    • 1 个回答
  • Marko Smith

    正确更新数据库中的数据

    • 1 个回答
  • Marko Smith

    Python解析不是css

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5