1.安装依赖    yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel 

2.home目录下创建nginx文件目录    mkdir nginx

3.下载nginx包  wget http://nginx.org/download/nginx-1.13.8.tar.gz

4.解压nginx   tar -xvf nginx-1.13.8.tar.gz

5.在nginx目录下执行  ./configure

6.查看是否有make    make -v(没有执行 yum -y install gcc automake autoconf libtool make)

7.安装nginx  make && make install  

8.通过你安装的linux ip访问  是否有东西  有救说明安装成功

7.修改  nginx/conf/nginx.conf文件内容 

        加在server里面

        location / {
            root   /vue/dist/; #你vue打包dist的在Linux的地址
                  try_files $uri $uri/ /index.html;
            index  index.html index.htm;
        }

         location /prod-api/{     #vue访问后端接口地址
                  proxy_set_header Host $http_host;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header REMOTE-HOST $remote_addr;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_pass http://你的后端接口的ip:端口/;
            }

 

修改之后进入sbin目录  ./nginx -t查看是否存在错误配置文件    ./nginx -s reload重启nginx命令

若依vue打包

        1. vue.config.js 修改 publicPath: './'    //请根据自己路径来配置更改

        2.export default new Router({   mode: 'hash', // hash模式 })

        3.打包命令 npm run build:prod

若依nginx配置http://doc.ruoyi.vip/ruoyi-vue/document/hjbs.html#nginx%E9%85%8D%E7%BD%AE

Logo

快速构建 Web 应用程序

更多推荐