(1)下载

wget http://nginx.org/download/nginx-1.12.2.tar.gz

(2) 安装依赖

yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel

(3) 解压

tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2/

(4) 执行配置

./configure

(5) 编译安装

make
make install

(6) 设置反向代理

location /api{
            # rewrite ^/app\/(.*)$ /$1 break;
            proxy_pass http://localhost:10070;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout 10;
            proxy_send_timeout 10;
            proxy_read_timeout 10;
        }
        location / {
            root   /DATA/work/build;
            index  index.html;
        }

(7) 安装遇到问题
执行./configure时报错:
./configure: error: C compiler cc is not found
执行以下命令:
yum -y install gcc gcc-c++ autoconf automake make

错误为:./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel

错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.
安装:yum -y install openssl openssl-devel

错误提示:./configure: error: the HTTP gzip module requires the zlib library.
安装:yum install -y zlib-devel


stray
129 声望10 粉丝