nginx基本运行命令

2019-03-06 23:43|来源: 网路

启动

[root@master local]# /usr/sbin/nginx -c/etc/nginx/nginx.conf

nginx: [emerg] mkdir()"/var/tmp/nginx/client" failed (2: No such file or directory)

[root@master local]# mkdir -pv/var/tmp/nginx/client

mkdir: 已创建目录 "/var/tmp/nginx"

mkdir: 已创建目录 "/var/tmp/nginx/client"

[root@master local]# /usr/sbin/nginx -c/etc/nginx/nginx.conf


查看服务是否启动

[root@master local]# ps -ef | grep nginx

root     5598     1  0 23:10 ?        00:00:00 nginx: master process/usr/sbin/nginx -c /etc/nginx/nginx.conf

nginx     5599 5598  0 23:10 ?        00:00:00 nginx: worker process                  

root     5603  1813  0 23:10 pts/0    00:00:00 grep nginx


查看监听端口

[root@master local]# netstat -tulnp | grepnginx

tcp       0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      5598/nginx


浏览器访问:



停止

从容关闭

[root@master local]# kill -QUIT $(cat/var/run/nginx/nginx.pid)

快速停止

[root@master local]# kill -TERM $(cat/var/run/nginx/nginx.pid)

强制结束nginx进程

[root@master local]# kill -9 5631


重启

[root@master local]# kill -HUP $(cat/var/run/nginx/nginx.pid)


检测配置文件语法是否正确

[root@master local]# /usr/sbin/nginx -t -c/etc/nginx/nginx.confnginx: the configuration file /etc/nginx/nginx.conf syntaxis ok

nginx: configuration file/etc/nginx/nginx.conf test is successful



相关问答

更多
  • 1.[root@localhost ~]# ps -ef grep nginx 看是否存在主进程和php-fpm子进程 nginx: master process 00:00:00 php-fpm:xxx 2.查看nginx监听的端口是否存在 [root@localhost ~]# netstat -tlnupgrep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12891/nginx 3.如果nginx已经做成服务 [root@localhost ~]# servi ...
  • 有时想知道nigix是否在正常运行,需要用linux命令查看nginx运行情况。 执行命令: ps -A | grep nginx 如果返回结果的话,说明有nginx在运行,服务已经启动。 如果不怕nginx关闭的话。也可以执行: service nginx restart 把nginx服务重启,在重启时,也可以看到具体有没有什么地方出错。
  • Nginx对应的端口号是否在监听, 看看Nginx配置文件中有没有写log文件的存储位置,找到Nginx的Log文件,查看分析一下。
  • 你好。 1. Nginx对应的端口号是否在监听, 2. 看看Nginx配置文件中有没有写log文件的存储位置,找到Nginx的Log文件,查看分析一下。
  • Linux每个应用运行都会产生一个进程,那么我们就可以通过查看Nginx进程是否存在来判断它是否启动。 1、有时想知道nigix是否在正常运行,需要用linux命令查看nginx运行情况。执行命令:ps -A | grep nginx。 如果返回结果的话,说明有nginx在运行,服务已经启动。如果不怕nginx关闭的话。也可以执行:service nginx restart。 把nginx服务重启,在重启时,也可以看到具体有没有什么地方出错。 2、看端口netstat -ntlp; 看进程ps -ef|gr ...
  • 1.[root@localhost ~]# ps -ef |grep nginx 看是否存在主进程和php-fpm子进程 nginx: master process 00:00:00 php-fpm:xxx 2.查看nginx监听的端口是否存在 [root@localhost ~]# netstat -tlnup|grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12891/nginx 3.如果nginx已经做成服务 [root@localhost ~]# ser ...
  • 1.[root@localhost ~]# ps -ef |grep nginx 看是否存在主进程和php-fpm子进程 nginx: master process 00:00:00 php-fpm:xxx 2.查看nginx监听的端口是否存在 [root@localhost ~]# netstat -tlnup|grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12891/nginx 3.如果nginx已经做成服务 [root@localhost ~]# ser ...
  • 1、可以ps检查进程,也可以看端口 netstat -ntlp|grep nginx 2、nginx -t测试配置是否正常 3、/etc/init.d/nginx status或systemct status nginx监测进程是否正常
  • 1. 你可以通过ps -ef | grep nginx查看有没有nginx进程 2. 你可以查看nginx运行的端口,一般为80端口,lsof -i:80 3. top命令看一会,看看有没有nginx这个名字的进程,推荐前两种方法
  • location / { # ... if ($args ~ "flush=1") { # do something } # ... } 至于execute shell command你可以试试lua-nginx-module 。 content_by_lua 'os.execute("")'; location / { # ... if ($args ~ "flush=1") { # do something } # ... } As for exec ...