1、打開https://brew.sh/index_zh-cn
2、brew search nginx brew install nginx
3、brew info nginx
4、nginx -v 查看nginx信息
5、啟動sudo brew services start nginx (默認端口8080)//太傻
備注:如果你安裝過Jenkins的話這里失效
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
systemctl start jenkins
6、關閉sudo brew services stop nginx/nginx
7、nginx -s reload、nginx -s stop //開啟、關閉
8、打開Nginx具體安裝目錄 查看配置文件 /usr/local/etc/nginx/
9、驗證配置文件 nginx -t -c 自己的配置文件地址
10、拷貝配置文件至Node 項目目錄 重新修改
11、服務器端的nginx地址
//給運維留的文件 http{ upstream firsttest{ server 192.168.1.1; //需要反向代理的地址 server 192.168.1.2; // 需要反向代理的地址 } server{ listen:8080; localhost / { proxy_pass:http://firsttest; } } }
12、幾條蓋世絕學
ps aux | grep node
lsof -i tcp:8081
kill -9 pid
ssh 用戶名@地址(免密登陸)
scp course-map.json root@ip地址:/路徑
scp -r advance/ root@101.200.185.250:/opt/node-publish/www/static/
13、npm install --production 只管上線環境
14、pm2動態檢測文件
14-1 能夠動態的監控文件的上傳0秒熱啟動
14-2 能夠負載均衡 CPU
14-3 內存的使用 過高了 CPU調度太頻繁 重啟。
14-4 restart 個數
pm2.json
//pm2
1、pm2 log 查看錯誤
2、pm2 start pm2.json //啟動
3、pm2 stop all //停止所有pm2
4、pm2 monit //監控
5、pm2 //線上監控地址https://app.keymetrics.io/
pm2命令地址參考 https://blog.csdn.net/chengxuyuanyonghu/article/details/74910875
nginx 做反向代理/負載均衡會出現一個坑
/usr/local/etc/nginx/ //目錄地址
ngxin -s reload //出現這個錯誤
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
//解決方法:找到你的nginx.conf的文件夾目錄,然后運行這個nginx -c /usr/local/etc/nginx/nginx.conf
命令,
再運行nginx -s reload
,就可以了