brew install nginx
注释: brew 安装ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装完之后,可以在终端看到路径信息/usr/local/etc/nginx/nginx.conf (配置文件路径) /usr/local/var/www (服务器默认路径) /usr/local/Cellar/nginx/1.8.0 (安装路径)
假如是macOS 1.12以上的系统,在安装过程中可能会出现”warning”,说是不支持该版本的操作系统,可以暂时先忽略它。
ps -ef|grep nginx
看能否有启动/usr/local/Cellar/nginx/1.8.0/bin/nginx -c /usr/local/etc/nginx/nginx.conf
肯定要注意路径能否是自己的安装路径/usr/local/Cellar/nginx/1.8.0/bin/
目录下 执行sudo ./nginx
ps -ef|grep nginx
获取到nginx的进程号, 注意是找到“nginx:master”的那个进程号kill -QUIT 15800 (从容的中止,即不会立刻中止)
Kill -TERM 15800 (立刻中止)
Kill -INT 15800 (和上面一样,也是立刻中止)
promote:bin yangqianhua$ /usr/local/Cellar/nginx/1.8.0/bin/nginx -t -c /usr/local/etc/nginx/nginx.conf
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
在终端输入输入如下命令就可重启promote:~ yangqianhua$ cd /usr/local/Cellar/nginx/1.8.0/bin/
promote:bin yangqianhua$ ./nginx -s reload
根据进程号重启,执行命令 kill -HUP
进程号
sudo find / -name nginx* 强制全局搜索nginx相关文件
cd 到bin目录下执行./ngnix
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied) 2018/09/18 16:53:12 [emerg] 9734#0: open() "/usr/local/Cellar/nginx/1.15.3/logs/error.log" failed (2: No such file or directory)
操作 cd /usr/local/Cellar/nginx/1.15.3/ 新建logs目录增加error.log文件, 执行sudo nginx 出现如下错误
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256 localhost:bin hello_xie$ nginx: [warn] 1024 worker_connections exceed open file resource limit: 256 -bash: nginx:: command not found localhost:bin hello_xie$ nginx: [warn] 1024 worker_connections exceed open file resource limit: 256 -bash: nginx:: command not found
执行 ulimit -acore file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 256 pipe size (512 bytes, -p) 1 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 1418 virtual memory (kbytes, -v) unlimited
执行 ulimit -n 1024
sudo nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
到 nginx.conf 文件增加 worker_rlimit_nofile 1024
;这种入侵性更小, 推荐使用
要在Nginx.conf文件 最开始的地方加权限user root owner
而后重启或者者重新加载Nginx
"/usr/local/var/run/nginx/client_body_temp/0000000004" failed (13: Permission denied), client: 127.0.0.1, server: localhost, request: "POST /vip/doc/docs?userId=admin&userName=%E7%AE%A1%E7%90%86%E5%91%98&sysCode=ivs&businessModel=frameworkAppr HTTP/1.1", host: "localhost:3000", referrer: "http://localhost:3000/"
#chmod -R 755 /usr/local/var/run/nginx/client_body_temp