centos8 linux部署node项目
生活随笔
收集整理的這篇文章主要介紹了
centos8 linux部署node项目
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1、域名解析到服務器
2、上傳代碼到項目目錄
3、數(shù)據(jù)庫:
mongo
use user
user是數(shù)據(jù)庫名
db.nfrc.insert({“name”:admin,“pawwsord”:“123456”})
nfrc集合名,相當于表名
db.nfrc.find()
數(shù)據(jù)行的id和項目中routes文件下index.js里面的id相一致
4、配置nginx.conf
文件:/usr/local/nginx/conf/nginx.conf
cd /usr/local/nginx/conf/sites 新建域名文件(靜態(tài)/動態(tài))
端口和node項目中的www文件的端口一致
注意反向代理的名字:proxy_pass和upstream 名字一致 (本文第六節(jié))
配置完:nginx -t
重啟:nginx -s reload
5、到項目里面啟動
pm2 start ./bin/www --name="項目名"
查看是否報錯
6、瀏覽器打開:
upstream **fff.yy877.top** {server 127.0.0.1:3030;keepalive 64; } server {listen 80;server_name fff.yy877.top;#access_log /home/wwwlogs/abc.com.log access;location / {proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $http_host;proxy_set_header X-Nginx-Proxy true;proxy_set_header Connection "";proxy_pass **http://fff.yy877.top**;}}總結
以上是生活随笔為你收集整理的centos8 linux部署node项目的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux 系统安装mongodb数据库
- 下一篇: linux系统安装宝塔面板