首页 > 系统相关 >1. 查看NGINX是否在运行. 四种方式 nginx的配置文件的路径: /etc/nginx/nginx.conf

1. 查看NGINX是否在运行. 四种方式 nginx的配置文件的路径: /etc/nginx/nginx.conf

时间:2022-10-11 09:01:06浏览次数:47  
标签:00 grep 配置文件 04 etc process 0.0 nginx

  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

http://t.zoukankan.com/niewd-p-12848844.html

标签:00,grep,配置文件,04,etc,process,0.0,nginx
From: https://www.cnblogs.com/sunny3158/p/16778060.html

相关文章

  • [LeetCode] 1328. Break a Palindrome
    GivenapalindromicstringoflowercaseEnglishletters palindrome,replace exactlyone characterwithanylowercaseEnglishlettersothattheresultingst......
  • vite配置文件语法提示以及开发环境和生产环境区分
    1.让vite.config.js具备语法提示:方法1:使用defineConfig方法:vite.config.js需要导出一个配置对象:exportdefault{...}但是这样是不会具备配置提示能力的,d......
  • nginx
    目录nginx简介nginx简介nginx(发音同enginex)是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like协议下发行。nginx由俄罗斯的程序......
  • Nginx
    一、Nginx是什么?Nginx(enginex)是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru......
  • nginx
    nginx目录nginxnginx简介nginx的特性nginx的工作原理部署nginxnginx简介nginx(发音同enginex)是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并......
  • LeetCode算法笔记 350. 两个数组的交集 II
    importjunit.framework.TestCase;importjava.util.Arrays;importjava.util.HashMap;publicclassLeetCode03extendsTestCase{/***350.两个数组......
  • Leetcode 11 -- 贪心
    题目描述最小字典许思路思路来源由于t中的字符后进先出,可以使用一个暂存栈来保存s删除的第一个字符入栈很简单,初始状态下,栈为空,我们可以直接入栈,因此,每次遍历我们......
  • leetCode 27. Remove Element
    [27.RemoveElement][(https://leetcode.cn/problems/remove-element/)思路数组在内存中是连续的,根据此题要求不能删除,而是覆盖暴力解法此题暴力解法是两层for......
  • nginx日志分析
    通过nginx日志利用shell统计日pv和uv网上记录nginx日志统计访问量的脚本的文档很多,但是看来看去实际都是一个东西,如下:1.根据访问IP统计UVawk'{print$1}'  access.lo......
  • leetcode-287. 寻找重复数-数组构成的链表
    287.寻找重复数由题中数字都在[1,n]范围内(包括1和n),可知至少存在一个重复的整数。维护一个映射关系f(n)=index->num,其中数组的下标index,数字为num当一......