---
title: "nginx安装,yum问题，make问题"
author: "xly1981"
date: "2018-11-21T16:38:18Z"
tags: []
categories: ["操作系统"]
slug: "nginx-yum-make"
draft: false
lastmod: "2018-11-23T13:42:03Z"
id: 2434143
url: "https://xly1981.iteye.com/blog/2434143"
---

一
首先总体按照
https://github.com/caojx-git/learn/blob/master/notes/nginx/nginx%E4%BD%BF%E7%94%A8stream%E6%A8%A1%E5%9D%97%E5%81%9Assh%E8%BD%AC%E5%8F%91.md
里面的安装流程。

二
注意如果不能访问外网，检查文件：
/etc/yum.repos.d/rhel-source.repo

其中的 baseUrl 表示下载镜像
也可以配置为本地目录

三
安装nginx时，提示nginx.conf文件存在
可以将这一步改一下
./configure --prefix=/usr/local/nginx  
TO
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf  
然后配置文件路径就调整到nginx/nginx.conf位置

配置多个转发
stream段的配置要与http段在同级目录。此处引用的为官方nginx说明配置。
stream {
    upstream backend {
        hash $remote_addr consistent;
        server backend1.example.com:12345 weight=5;
        server 127.0.0.1:12345            max_fails=3 fail_timeout=30s;
        server unix:/tmp/backend3;
    }

    upstream dns {
       server 192.168.0.1:53535   max_fails=1  fail_timeout=3s;
       #server 127.0.0.1:8080 backup; 备
    }

    server {
        listen 12345;
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        proxy_pass backend;
    }

    server {
        listen 127.0.0.1:53 udp reuseport;
        proxy_timeout 20s;
        proxy_pass dns;
    }

    server {
        listen [::1]:12345;
        proxy_pass unix:/tmp/stream.socket;
    }
}