Nginx的简单操作

一、mac下安装Nginx

查看版本

brew search nginx

下载

brew install nginx

安装完以后,可以在终端输出的信息里看到一些配置路径:

/usr/local/etc/nginx/nginx.conf (配置文件路径)

/usr/local/var/www (服务器默认路径)

/usr/local/Cellar/nginx/1.12.2 (安装路径)

二、启动

在终端中输入

cd /usr/local/Cellar/nginx/1.12.2/bin(cd到安装目录)

sudo nginx(启动nginx)

输入ps -ef|grep nginx

如果执行的结果是

0 1055 1 0 12:34下午 ?? 0:00.00 nginx: master process nginx
-2 1056 1055 0 12:34下午 ?? 0:00.00 nginx: worker process
501 1058 1029 0 12:34下午 ttys000 0:00.00 grep nginx

表示已启动成功

这时候访问localhost为nginx的欢迎页面

三、停止

在终端中输入 ps -ef|grep nginx 获取到nginx的进程号,注意是找到“nginx:master”的那个进程号,如下面的进程号是 1055

0 1055 1 0 12:34下午 ?? 0:00.00 nginx: master process nginx
-2 1056 1055 0 12:34下午 ?? 0:00.00 nginx: worker process
501 1058 1029 0 12:34下午 ttys000 0:00.00 grep nginx

在终端中输入以下几种命令都可以停止

sudo kill -QUIT 1055 (从容的停止,即不会立刻停止)

Kill -TERM 15800 (立刻停止)

Kill -INT 15800 (和上面一样,也是立刻停止)

四、重启

sudo nginx -s reload(需要在安装目录下执行/usr/local/Cellar/nginx/1.12.2/bin)

posted @ 2017-10-23 17:43  兔儿面  阅读(160)  评论(0编辑  收藏  举报