- nuxt项目完成之后打包
项目在开发完成之后。
- 首先使用npm run build进行打包
- 把 static nuxt.config package.json .nuxt 拷贝到服务器 这里有个重点上传到服务器之后访问资源发现一堆错误。错误已经被我解决了就不贴错误的图片了。给大家说一下怎么解决的。将assets资源文件也拷贝一起上传到服务器。
- 服务器环境要求
- node一定要8.12.0版本以上才行
- 首先执行npm install
- 然后执行npm start
- 成功之后再安装pm2 启动
- Nginx反向代理
在配置Nginx的时候也遇到了好多问题
这里直接给大家贴一个我成功的案例
server {
listen 80;
listen 443 ssl http2;
server_name 这里写自己的域名;
index index.html index.htm index.php;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
include /usr/local/nginx/conf/rewrite/other.conf;
#error_page 404 /404.html;
#error_page 502 /502.html;
location ~ [^/].php(/|$) {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
proxy_pass http://127.0.0.1:3000; //这个地方是重点 静态资源的访问
}
location ~ .*.(js|css)?$ {
proxy_pass http://127.0.0.1:3000; //这个地方是重点 静态资源的访问
expires 7d;
access_log off;
}
location ~ /.ht {
deny all;
}
//整个反向代理只需要加这样一句话就行了
location ~ {
proxy_pass http://127.0.0.1:3000;
}
}
以上就是本人经过了周末软磨硬泡弄出来的
刚开始写 写的不好 希望大佬轻喷
有搭建不懂的这块可以私信我
能帮到的尽量帮大家