- 修改nuxt的
nuxt.config.js
,新增如下配置
server: {
port: 3000, // default: 3000
host: '0.0.0.0' // default: localhost,
}
- 将项目clone到服务器上如下(nuxt_koa_mongodb)
/home/nginx
cd /etc/nginx
cd conf.d
touch nuxt_koa_mongodb.conf
- nuxt_koa_mongodb.conf(目前简单实用这个配置)
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
listen 3000;
#server_name nuxtdemo.com;
gzip on;
gzip_types text/plain application/xml application/javascript text/css text/xml;
gzip_min_length 1000;
location / {
expires $expires;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:3000;
}
}
nginx -s reload
npm run build
npm run start
cnpm i pm2 -g
ln -s /usr/local/node/bin/pm2 /bin/pm2
pm2 start npm --name "nuxt_koa_mongodb" -- run start
git pull
npm run build
pm2 reload [id]
网友评论