1.1.Linux操作系统

nginx-1.19.4.tar.gz    在虚拟机上运行
上传到指定目录中 /usr/local/src  -> tar -xvf nginx-1.19.4.tar.gz 解压Nginx 压缩文件
->rm -f nginx-1.19.4.tar.gz 删除文件包 -> mv nginx-1.19.4   nginx-source 修改文件名称
->cd nginx-source 进入nginx-source文件中 ->./configure 校验程序是否正常->make 编译程序
->make install 安装程序 ->whereis nginx 查找工作目录 ->cd /usr/local/nginx 进入这个目录
->Ls->cd sbin 进入nginx/sbin目录中执行 -> ./nginx 启动命令
1.启动命令: ./nginx
2.重启命令: ./nginx -s reload
3.关闭命令: ./nginx -s stop
->cd ..->cd conf/->右边目录 找到nginx.conf 右键 Download
->配置服务器与window一样 只改
root地址: root /usr/local/src/images;还有  集群   server 192.168.126.129:8092;
->cd ../ 根目录 ->将前端资源 dis 放在根目录下 ->usr/local/nginx/conf  删除里面的conf,将更改后的conf放进去  -> usr/local/nginx/sbin ->./nginx -s reload
->C:\Windows\System32\drivers\etc->hosts-> 将127.0.0.1改为192.168.126.129


 

1.2.window 操作系统

路径不要有汉字->nginx->右键->以管理员身份运行->在浏览器上localhost:80
打开nginx->cmd 回车->  1.启动命令  start nginx    --打开一次开两个
2.重启命令  nginx -s reload
3.关闭命令  nginx -s stop


​ 1.更改前端服务器的main前缀与additem中将localhost:8091改为manage.jt.com ​

2.运行vue ui->build ​

3.将前端dist中的文件复制到nginx文件夹中 ​

4.nginx->cmd 回车

​ 图片回显,可以预览 ​ ​

conf 配置文件->nginx.conf->在最后-> #配置图片服务器 ​

     #拦截域名:​​http://image.jt.com​​ ​

   #代理路径:D:/images ​

     server{ ​

     listen 80; ​

     server_name image.jt.com; ​

     location / { ​

     root D:/images; ​

     } ​

       }

 

 

​ ​     ​ #最后的括号是http的结束 ​

     ​ #配置前端服务器 ​​www.jt.com​​ ​

      server{ ​

         listen 80; ​

        server_name ​​www.jt.com​​; ​

         location / { ​

         root dist; ​

       index index.html;

          ​ } ​

           }

 

 

 

 

​ ​ ​     ​ #定义tomcat集群 ​

       #负载均衡策略:1.轮询策略

      ​ upstream tomcats{ ​

        server 127.0.0.1:8091; ​

        server 127.0.0.1:8092; ​

         }

         ​ #配置后端服务器 manage.jt.com 8091/8092 ​

           server{

            ​ listen 80; ​

           server_name manage.jt.com; ​

           location / { ​

         #代理的是一个请求路径 ​

           proxy_pass ​​http://tomcats​​;

             ​ }

              ​ }

 

 

​ ​    C:\Windows\System32\drivers\etc->hosts-> # IP 与 域名映射 ​

          # 127.0.0.1 localhost ​

           # ::1 localhost ​

           #图片服务器配置 ​

           127.0.0.1 image.jt.com ​

           #前端服务器配置 ​

           127.0.0.1 ​​www.jt.com​​ ​

           #后端服务器配置 ​

           127.0.0.1 manage.jt.com