• 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

  • 相关阅读:
    Bootstrip的相关介绍
    Django的ORM主外键约束实现
    Django基于ORM数据库配置
    Django的安装与配置
    ORM(关系对象映射)框架之面向对象
    pymysql模块的数据操作
    SQL语句实践
    mysql 数据库的基本操作语法
    算法训练 矩阵乘法
    算法训练 字串统计
  • 原文地址:https://www.cnblogs.com/niewd/p/12848844.html
Copyright © 2020-2023  润新知