![](https://csdnimg.cn/release/download_crawler_static/9472918/bg3.jpg)
作者:王亚超
在两台负载均衡服务器上安装 nginx 步骤:
1、安装依赖
在安装 nginx 前,需要确保系统安装了 g++、gcc、openssl-devel、pcre-devel 和
zlib-devel 软件。安装必须软件:
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-d
evel
2、下载源码、解压、编译、安装
a. wget http://nginx.org/download/nginx-1.8.1.tar.gz
b. tar -zxvf nginx-1.8.1.tar.gz
c. cd nginx-1.8.1
d. ./configure --prefix=/usr/local/nginx \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre
e. make
f. make install
注:--prefix=/usr/local/nginx 指定安装目录
vi /usr/local/nginx/conf/nginx.conf
upstream web1
{
ip_hash;
server 192.168.137.4:80;
server 192.168.137.5:80;
}
server {
listen 80;
server_name test.test007.com;
location / {
root /var/www;
index index.html index.htm;
proxy_set_header Host $host;