【问题标题】:nginx is started but not found service on ubuntunginx 已启动但在 ubuntu 上找不到服务
【发布时间】:2017-03-20 17:50:03
【问题描述】:

我尝试在 ubuntu 16.04 上重新启动 apache 服务,但我不能,因为 nginx 监听了端口“80”。 但是当我尝试停止 nginx 时,找不到该服务。

netstat -ltnp | grep ':80'
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6069/nginx


    systemctl status nginx
● nginx.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)

service nginx stop
Failed to stop nginx.service: Unit nginx.service not loaded.

那么我怎样才能停止 nginx 以重新启动 apache 呢?

感谢您的帮助

【问题讨论】:

    标签: apache ubuntu nginx


    【解决方案1】:

    您机器上的 nginx 以其他方式启动,然后是 systemd 标准 nginx 服务。

    alex@openresty:~$ ps aux | grep nginx
    root      2668  0.0  0.0  41040   928 ?        Ss   12:33   0:00 nginx: master process /usr/local/openresty/bin/openresty -p /usr/local/openresty/nginx/
    nobody    2669  0.0  0.0  41040  3316 ?        S    12:33   0:00 nginx: worker process
    

    将向您展示使用命令行参数运行 nginx 的完整路径。这是我的 PC 中的示例(我使用 Openresty 包,因此您的路径可能会有所不同)。

    现在来看看nginx主进程命令行参数。如果 -p 存在,您应该使用完全相同的方法来停止 nginx。就我而言,它应该是:

    /usr/local/openresty/bin/openresty -p /usr/local/openresty/nginx/ -s stop
    

    如果 -p 错过了,你可能只是

    /usr/local/openresty/bin/openresty -s stop
    

    它会停止 nginx,但有可能在您的 PC 上,nginx 被配置为作为非标准服务运行,例如手写的 systemd 单元。 所以每次重启时,你都会让 nginx 再次运行。

    【讨论】:

      猜你喜欢
      • 2019-06-30
      • 1970-01-01
      • 2017-04-23
      • 2020-03-01
      • 2018-08-15
      • 1970-01-01
      • 2016-10-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多