• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Linux安装Nginx步骤

linux 搞代码 3年前 (2022-03-03) 22次浏览 已收录 0个评论
文章目录[隐藏]

Linux装置Nginx步骤

  1. Nginx装置步骤

=============

1.1 官网介绍

<code class="java">`http://nginx.org/en/download.html` 

*   1

1.2 上传安装包

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

1.3 解压Nginx 压缩文件


1.挪动装置目录到指定文件

<code class="java">`mv nginx-1.19.4.tar.gz software/` 

*   1

2.批改文件名称

<code class="java"> `mv nginx-1.19.4   nginx-source` 

*   1

1.4 对于nginx 目录阐明


改完名称之后的后果:

1.5 装置nginx服务器

阐明:在nginx-source的根目录中执行如下命令

  1. ./configure

    间接后果:
  2. 在nginx-source的根目录中 执行 make
  3. 根目录中执行 make install

1.6 Nginx工作目录阐明

阐明: 查找工作目录
门路: whereis nginx

1.7 跳转到Nginx工作目录

1.7.1 nginx命令

进入nginx/sbin目录中执行

1.启动命令: ./nginx
2.重启命令: ./nginx -s reload
3.敞开命令: ./nginx -s stop

1.7 批改nginx配置文件


需要阐明:
1.实现图片反向代理
2.实现tomcat负载平衡实现

具体实现:
批改实现之后,重启nginx服务器.

<code class="java">`#配置图片代理服务器  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;
    }` 

*   1
*   2
*   3
*   4
*   5
*   6
*   7
*   8
*   9
*   10
*   11
*   12
*   13
*   14
*   15
*   16
*   17
*   18
*   19
*   20
*   21
*   22
*   23
*   24
*   25
*   26
*   27
*   28
*   29
*   30
*   31
*   32
*   33
*   34
*   35
*   36
*   37
*   38
*   39
*   40

1.8.批改hosts文件

阐明:因为没有购买image/manage.jt.com的域名,所以须要通过hosts文件批改转向.
批改windows中的hosts文件:

1.9成果展示


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Linux安装Nginx步骤

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址