• 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
    
  • 相关阅读:
    Python的17种骚操作
    Python使用pip下载慢的原因
    Mysql数据库的安装
    Python中遇到的难解的提示:
    Linux使用SecureCRT远程终端工具的使用
    Linux下IP命令使用详解
    (未解决)jmeter报错之“请在微信客户端打开链接”
    Python学习笔记系列——九九乘法表&猜大小
    《Mysql必知必会》笔记
    (未解决)记录一次登录&jmeter,留下的一地鸡毛
  • 原文地址:https://www.cnblogs.com/jkko123/p/6294559.html
Copyright © 2020-2023  润新知