基本命令

1. 入门

  1. 查看nginx进程: ps -ef|grep nginx

    404@40401:~$ ps -ef|grep nginx
    root      7996     1  0 Apr14 ?        00:00:00 nginx: master process nginx
    404     14126  6118  0 11:56 pts/79   00:00:00 more nginx.conf
    404     18278  7635  0 13:16 pts/88   00:00:00 grep --color=auto nginx
    nobody   31455  7996  0 Jun01 ?        00:03:26 nginx: worker process
    nobody   31456  7996  0 Jun01 ?        00:03:35 nginx: worker process
    nobody   31457  7996  0 Jun01 ?        00:03:25 nginx: worker process
    nobody   31458  7996  0 Jun01 ?        00:03:40 nginx: worker process
    

    这里进程的话主要由nobody执行,为什么是4个事因为在ngin.conf中设置了四核

    ## worker_processes的数值设置为cpu的核数
    worker_processes  4;
    ## 绑定每个nginx进程所使用的CPU,使nginx可以利用cpu的多核
    worker_cpu_affinity 0001 0010 0100 1000;
    
  2. 检查配置文件的正确性: sudo nginx -t

    404@40401:~/env/nginx/default/conf$ sudo nginx -t
    [sudo] password for work:
    nginx: the configuration file 404/nginx.conf syntax is ok
    nginx: configuration file 404/nginx.conf test is successful
    
  3. 检查nginx完整配置信息: sudo nginx -V

     nginx -V
    
  4. 启动nginx:

    1. nginx
    2. nginx -s reload: 平滑启动nginx,表示不停止nginx的情况下重启nginx
  5. 停止nginx:

    1. 完美停止nginx: kill -QUITcat /var/run/nginx.pid``
    2. 快速停止nginx: kill -INTcat /var/run/nginx.pid``
    3. 完美停止工作进程,只要用作平滑升级: kill -WINCHcat /var/run/nginx.pid``
    4. 强制停止nginx: pkill -9 nginx
    5. 停止ngix: nginx -s stop

参考链接

基本命令参考 http://my.oschina.net/psuyun/blog/113694

© 404mzk all right reserved,powered by Gitbook该文件修订时间: 2017-04-09 09:07:59

results matching ""

    No results matching ""