当前位置: 首页 > Linux

Linux安装Nginx步骤

时间:2023-04-06 22:20:06 Linux

一、Nginx安装步骤1.1官网介绍Nginx官网1.2上传安装包上传到指定目录/usr/local/src1.3解压Nginx压缩文件1.将安装目录移动到指定文件mvnginx-1.19。4.tar.gzsoftware/2.修改文件名mvnginx-1.19.4nginx1.4关于nginx目录说明1.5安装nginx服务器说明:在源文件./configure中执行以下命令直接结果:2.make3.makeinstall1.6nginx命令说明:nginx工作目录说明命令:1.windows命令:1.启动命令:启动nginx2.重启命令:nginx-sreload3.关闭命令:nginx-sstop2.Linux命令1.启动命令:./nginx2.重启命令:./nginx-sreload3.关闭命令:./nginx-sstop1.7修改nginx配置文件要求:1.实现镜像反向代理2.实现tomcat负载均衡实现:修改完成后,重启nginx服务器。#配置图片代理服务器http://image.jt.com:80server{listen80;服务器名称image.jt.com;位置/{#rootD:/JT-SOFT/images;root/usr/local/src/images;}}#配置商品后台服务器server{listen80;服务器名称manage.jt.com;location/{#proxy真实服务器地址#proxy_passhttp://localhost:8091;#映射到集群#proxy_passhttp//jt视窗;proxy_passhttp://jtLinux;}}#配置tomcat服务器集群1.默认轮询策略2.权重策略3.ip_hash策略upstreamjtWindows{#ip_hash;失败次数#fail_timeout=60s如果访问失败,失败的机器在60秒内不会再次访问。服务器127.0.0.1:8081max_fails=1fail_timeout=60s;.0.1:8083max_fails=1fail_timeout=60s;}上游jtLinux{服务器192.168.126.129:8081;服务器192.168.126.129:8082;服务器192.168.126.129:8083;jt.com的域名,所以需要修改hosts文件在windows下修改hosts文件#京淘配置192.168.126.129image.jt.com192.168.126.129manage.jt.com#IP域名映射关系#127.0.0.1image.jt.com#127.0.0.1manage.jt.com127.0.0.1www.jt.com127.0.0.1sso.jt.com127.0.0.1localhost1.9效果展示