zoukankan      html  css  js  c++  java
  • 1. 查看NGINX是否在运行.

    1. 查看NGINX是否在运行.

    ps aux | grep nginx
    [root@bogon /]# ps aux | grep nginx
    root      2318  0.0  0.0  56816  1272 ?        Ss   5月04   0:00 nginx: master process /usr/sbin/nginx
    nginx     2319  0.0  0.0  57264  2232 ?        S    5月04   0:00 nginx: worker process
    nginx     2320  0.0  0.0  57264  2232 ?        S    5月04   0:00 nginx: worker process
    nginx     2321  0.0  0.0  57264  1992 ?        S    5月04   0:00 nginx: worker process
    nginx     2322  0.0  0.0  57264  1992 ?        S    5月04   0:00 nginx: worker process
    nginx     2323  0.0  0.0  57264  2228 ?        S    5月04   0:00 nginx: worker process
    nginx     2324  0.0  0.0  57264  2232 ?        S    5月04   0:00 nginx: worker process
    nginx     2325  0.0  0.0  57264  2228 ?        S    5月04   0:00 nginx: worker process
    nginx     2326  0.0  0.0  57264  1992 ?        S    5月04   0:00 nginx: worker process
    root     21470  0.0  0.0 112732   968 pts/0    S+   09:56   0:00 grep --color=auto nginx
    

    第一种方法:查看进程列表并过滤

    Linux每个应用运行都会产生一个进程,那么我们就可以通过查看Nginx进程是否存在来判断它是否启动。

    用ps -ef列出进程列表,然后通过grep过滤。

    如: ps -ef | grep nginx 就可以看到度Nginx进程是否存在了

         ps -ef   | grep httpd

       netstat -tlnp | grep 端口号(默认是80) 

       lsof -i :端口号

    第二种方法:直接查看进程id

    ps -C nginx -o pid

    这种直接返回pid的方式比较适合跟其他程序结合使用,比如在shell/python脚本中执行这个命令拿到pid,让后回根据pid来判断Nginx是否启动。 

    通过端口判断

    第三种方法:使用netstat命令

    如果我们的Nginx运行在80端口,那么就可以通过netstat -anp | grep :80命令来判断Nginx是否启动。

    第四种方法:使用lsof命令

    lsof -i:80 也可以查到80端口进程是否有进程在答运行。

    ps -A | grep nginx 也可以

    2. 查看NGINX配置是否正确

    [root@bogon /]# nginx -t 
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful

    nginx的配置文件的路径: /etc/nginx/nginx.conf

  • 相关阅读:
    dede模板留言提交错误时返回空白页处理方法
    Dedecms列表页通过函数调用当前文档tag的方法
    织梦dedecms如何让内容页显示不同的内容,但是每次更新都不变
    织梦DedeCMS网站服务器搬家详细教程
    让DEDECMS文章内容中链接新窗口打开的方法
    织梦dedecms中英文模版当前位置的修改方法
    织梦dedecms设置不同的搜索页模板教程
    简易版php文件上传_超详细详解
    nodejs 使用mongoose 操作mongodb
    记一个正则
  • 原文地址:https://www.cnblogs.com/niewd/p/12848844.html
Copyright © 2011-2022 走看看