nginx 负载均衡 配置

 

 

1.下载 gz.tar

  

nginx-1.8.1.tar.gz
openssl-1.0.1c.tar.gz
pcre-8.37.tar.gz
zlib-1.2.8.tar.gz

2.安装 以上 软件

  

tar -zxvf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make
make install

tar -zxvf openssl-1.0.1c.tar.gz
cd openssl-1.0.1c/
./config
make
make install

tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure
make
make install

tar xzf nginx-1.8.1.tar.gz
cd nginx-1.8.1/
./configure  --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.1c
make
make install

 

注意:

configure: error: You need a C++ compiler for C++ support
正解
yum install -y gcc gcc-c++

 

测试安装成功否:

cd  /usr/local/nginx/sbin
./nginx -t

  显示 test is successful

 

 

启动 
cd  /usr/local/nginx/sbin
./nginx

关闭
./nginx -s stop 

重启 
./nginx -s reload

 

 

 负载均衡 配置

upstream test{
     #ip_hash;
     server 192.168.1.251;
     server 192.168.1.252;
     server 192.168.1.247;
 }
server {
    listen       80;
    server_name  helloword;
    location / {
         #反向代理的地址
         proxy_pass http://test;     
    }
}

 

 

 

 

你可能感兴趣的:(nginx,安装,配置)