1.下载nginx

1.1官网下载

官网:http://nginx.org/en/download....
windows零碎下关上官网下载一个linux零碎的nginx,之后再传到linux零碎中,这样比间接在yum中下载的版本更新些;

1.2上传安装包

上传到指定目录中/usr/local/src/

1.3解压nginx压缩包

命令:tar -xvf 包名

1.3.1解决压缩包

把压缩包挪动到指定目录下或删除,software目录是为了对立治理压缩包而创立的目录

1.3.2批改文件名

1.4装置nginx服务器

1)在nginx-source的根目录中执行命令: ./configure

实现

2)在nginx-source的根目录中执行命令: make
[root@localhost nginx-source]# make

3)在nginx-source的根目录中执行命令: make install
[root@localhost nginx-source]# make install

1.5跳转到nginx的工作目录

1.5.1查找nginx工作目录

命令:whereis nginx

1.5.2跳转

1.6启动nginx

1)进入nginx/sbin目录中
2)在sbin目录下执行启动命令
启动命令: ./nginx
重启命令: ./nginx -s reload
敞开命令: ./nginx -s stop

1.7批改nginx配置文件

1.7.1需要:

1)实现图片反向代理
2)实现tomcat负载平衡实现

1.7.2.关上配置文件

地位:/usr/local/nginx/conf/nginx.conf

关上nginx.conf文件

批改配置文件

`server {    #配置图片代理服务器  http://image.jt.com:80    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;}

`

1.7.3批改实现后重启nginx

重启命令: ./nginx -s reload

1.8批改hosts文件

1.8.1hosts文件阐明

应用域名拜访服务器须要把域名进行解析,hosts能够对本机的域名进行解析,能满足测试的需要,但商品一上线就须要花钱注册域名了,hosts就不能够了;

1.8.2批改hosts

批改的时候须要用到超级管理员的权限,关上的形式用以管理员形式关上;