【nginx】常用命令 启动|停止|重启|重新读取配置-centOS7

 查看服务的当前状态

(flaskApi) [root@67 goTest]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since 一 2019-10-21 13:52:34 CST; 3min 56s ago
 Main PID: 25799 (nginx)
   CGroup: /system.slice/nginx.service
           ├─25799 nginx: master process /usr/sbin/nginx
           ├─25800 nginx: worker process
           ├─25801 nginx: worker process
           ├─25802 nginx: worker process
           └─25803 nginx: worker process

10月 21 13:52:34 67.59.247.60.static.bjtelecom.net systemd[1]: Starting The nginx HTTP and r....
10月 21 13:52:34 67.59.247.60.static.bjtelecom.net nginx[25793]: nginx: the configuration fi...k
10月 21 13:52:34 67.59.247.60.static.bjtelecom.net nginx[25793]: nginx: configuration file /...l
10月 21 13:52:34 67.59.247.60.static.bjtelecom.net systemd[1]: Started The nginx HTTP and re....
Hint: Some lines were ellipsized, use -l to show in full.

启动nginx服务

systemctl start nginx.service

停止nginx服务

systemctl stop nginx.service 

 重新启动服务

systemctl restart nginx.service

重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)

systemctl reload nginx.service

调试

nginx默认日志目录(可以在nginx.conf配置文件中配置)

/var/log/nginx/

  时实查看nginx代理的请求

(线上调试可用--如何确认线上的请求是否生效?发送请求,如果access.log记录到日志,说明请求已经走到nginx,如果没有记录到日志,说明该请求没有走到Nginx,检查一下nginx.conf配置文件是否生效)

tail -f access.log

 

 查看前50行

tail -n 50 access.log

 

 

 

参考文档:写的超全,又清楚又详细!

centos7安装Nginx配置自启动命令

 

另:最新版本的nginx启动后,通过浏览器访问,不再是熟悉的welcome to nginx页面,而是下面这样子了

 

posted @ 2019-10-21 15:57  wangju003  阅读(2379)  评论(0编辑  收藏  举报