nginx反向代理架构与安装配置(一)

这里我们准备四台虚拟机,二台负载均衡(LB01,LB02),二台web服务器(WEB01,WEB02)。
 
这里默认所有软件都安装在/data目录下。
 
四台虚拟机的初始安装是centos7的最小安装,并执行如下命令。
> yum -y install gcc gcc-c++ kernel-devel
配置网络(虚拟机的网络连接设置成桥接模式)
> vi /etc/sysconfig/network-scripts/ifcfg-eno16777736

修改如下

BOOTPROTO=static
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.10.111
GATEWAY=192.168.10.1

重启网络

> service network restart

剩余的三台配置如上,IP分别为(192.168.10.122,192.168.10.133,192.168.10.144)

然后分别给四台虚拟机设置hostname,便于区分。

> hostname LB01
> hostname LB02
> hostname WEB01
> hostname WEB02

分别在四台虚拟机上安装pcre和nginx服务器

> cd /data
> tar xf pcre-8.39.tar.gz
> cd pcre-8.39
> ./configure --prefix=/data/pcre
> make && make install
> cd /data
> tar xf nginx-1.10.2.tar.gz
> cd nginx-1.10.2
> ./configure --prefix=/data/nginx \
--with-pcre=/data/pcre-8.39 \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_stub_status_module
> make && make install

(*--with-pcre指定的是pcre的源码目录,不是安装目录)

如果出现如下错误:

./configure: error: the HTTP gzip module requires the zlib library
./configure: error: SSL modules require the OpenSSL library

安装zlib

> yum -y install zlib zlib-devel openssl openssl-devel

启动nginx

> /data/nginx/sbin/nginx

如果出现如下问题:

nginx: [emerg] getpwnam("nginx") failed

说明没有nginx这个用户

> useradd nginx -s /sbin/nologin -M

 

 

 

相关文章

文章浏览阅读3.7k次,点赞2次,收藏5次。Nginx学习笔记一、N...
文章浏览阅读1.7w次,点赞14次,收藏61次。我们在使用容器的...
文章浏览阅读1.4k次。当用户在访问网站的过程中遇到404错误时...
文章浏览阅读2.7k次。docker 和 docker-compose 部署 nginx+...
文章浏览阅读1.3k次。5:再次启动nginx,可以正常启动,可以...
文章浏览阅读3.1w次,点赞105次,收藏182次。高性能:Nginx ...