项目打包上传服务器

1.将打包后的dist文件放入自己服务器中(/root/apps/xxx文件夹下)。

2.开放服务器防火墙端口

3.配置nginx(/etc/nginx/nginx.conf)

具体配置代码如下:

server {
        //开放的防火墙端口号
        listen       8282;
        server_name  localhost;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        location / {
        root  /root/apps/shangpinghui/dist;
        index  index.html index.htm;
//解决刷新页面变成404问题的代码
        try_files  $uri $uri/ /index.html;
       }

       location /api {
//解决跨域  跨域数据接口
       proxy_pass  http://gmall-h5-api.atguigu.cn;
       }
        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_48018288/article/details/127209362
今日推荐