nginx服务搭建

对nginx相关命令不熟悉,整理下nginx的命令,以备查阅

安装 nginx
brew install nginx

Homebrew为包管理器,将软件包安装到独立目录/usr/local

目录解析
/usr/local/etc/nginx/nginx.conf (配置文件路径)
/usr/local/var/www (服务器默认路径)
/usr/local/Cellar/nginx/1.15.9 (安装路径)

查看帮助

➜  bin nginx -h
nginx version: nginx/1.15.9
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/Cellar/nginx/1.15.9/)
  -c filename   : set configuration file (default: /usr/local/etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

nginx 启动管理

使用nginx命令管理

启动

sudo nginx

停止

sudo nginx -s  stop

重启

sudo nginx -s  reload

使用进程号管理

查看 nginx 进程

ps -ef|grep nginx

ps 进程查看命令
-ef 为标准显示进程格式

➜  bin ps -ef|grep nginx
    0 17523     1   0  7:29下午 ??         0:00.00 nginx: master process nginx
   -2 17524 17523   0  7:29下午 ??         0:00.00 nginx: worker process
  501 17616 14704   0  7:46下午 ttys000    0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx

查找nginx:master进程号:17523

适当时候停止

kill -QUIT 17523

立即停止

Kill -TERM 17523

立即停止

Kill -INT 17523

你可能感兴趣的:(nginx服务搭建)