1、下载Nginx
官网:http://nginx.org/en/download....
2、上传安装包
3、解压Nginx压缩文件
命令:tar -xvf nginx压缩包名
1、挪动装置目录到指定文件
mv nginx-1.19.4.tar.gz 指定文件夹/
2、批改文件名称
mv nginx-1.19.4 nginx
4、对于Nginx的目录阐明
5、在源文件中执行如下命令
阐明:在源文件中执行如下命令
1、命令:./configure
执行的后果
2、命令:make
3、命令:make install
6、nginx命令阐明
阐明: nginx工作目录阐明
门路:
cd /usr/local/nginx/
cd sbin/
执行nginx:./nginx
命令:
1、windows命令 1、启动命令 start nginx 2、重启命令 nginx -s reload 3、敞开命令 nginx -s stop2、Linux命令 1、启动命令 ./nginx 2、重启命令 ./nginx -s reload 3、敞开命令 ./nginx -s stop
7、批改nginx配置文件
需要阐明:
1、实现图片反向代理2.实现tomcat负载平衡实现
具体实现:
批改实现之后,重启nginx服务器
#配置图片代理服务器 http://image.jt.com:80 server { listen 80; server_name image.jt.com; location / { #root D:/JT-SOFT/images; root /usr/local/src/images; } } #配置商品后盾服务器 server{ listen 80; server_name manage.jt.com; location / { #代理实在服务器地址 #proxy_pass http://localhost:8091; #映射到集群 #proxy_pass http://jtWindows; proxy_pass http://jtLinux; } } #配置tomcat服务器集群 1.默认 轮询策略 2.权重策略 3.ip_hash策略 upstream jtWindows { #ip_hash; down 标识宕机 backup 备用机 #max_fails=1 示意最大的失败次数 #fail_timeout=60s 如果拜访不通,则在60秒内,不会再次拜访故障机 server 127.0.0.1:8081 max_fails=1 fail_timeout=60s; server 127.0.0.1:8082 max_fails=1 fail_timeout=60s; server 127.0.0.1:8083 max_fails=1 fail_timeout=60s; } upstream jtLinux { server 192.168.126.129:8081; server 192.168.126.129:8082; server 192.168.126.129:8083; }
8、批改hosts文件
阐明:因为没有购买image/manage.jt.com的域名,所以须要通过hosts文件批改转向
批改windows中的hosts文件
# 京淘配置 192.168.126.129 image.jt.com192.168.126.129 manage.jt.com#IP 域名 映射关系#127.0.0.1 image.jt.com#127.0.0.1 manage.jt.com127.0.0.1 www.jt.com127.0.0.1 sso.jt.com127.0.0.1 localhost#bug 丢最初一个字母问题