Nginx 1.10.1 编译、配置文档(支持http_v2,TLSv1.2,openssl v1.0.2)

1、安装常用工具及基础包:

[root@localhost /]# yum -y install wget git vim make gcc gcc-c++ openssl-devel
[root@localhost /]# mkdir -p /usr/local/nginx/module

2、安装pcre模块:

[root@localhost /]# wget -P/usr/local/src/ http://nchc.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz 
[root@localhost /]# tar -xzvf /usr/local/src/pcre-8.39.tar.gz -C /usr/local/nginx/module/

3、安装OpenSSL模块:

[root@localhost /]# wget -P/usr/local/src/ https://www.openssl.org/source/openssl-1.0.2h.tar.gz
[root@localhost /]# tar -xzvf /usr/local/src/openssl-1.0.2h.tar.gz -C /usr/local/nginx/module/

4、安装zlib模块:

[root@localhost /]# wget -P/usr/local/src/ http://zlib.net/zlib-1.2.8.tar.gz
[root@localhost /]# tar -xzvf /usr/local/src/zlib-1.2.8.tar.gz –C /usr/local/nginx/module/

5、安装LuaJIT模块

[root@17track /]# wget -P/usr/local/src/ http://luajit.org/download/LuaJIT-2.0.4.tar.gz
[root@17track /]# tar -xzvf /usr/local/src/LuaJIT-2.0.4.tar.gz -C /usr/local/src/
[root@17track /]# cd /usr/local/src/LuaJIT-2.0.4
[root@17track LuaJIT-2.0.2]# make
[root@17track LuaJIT-2.0.2]# make install

6、安装lua-nginx-module模块

[root@localhost /]# wget -P/usr/local/src/ https://github.com/openresty/lua-nginx-module/archive/v0.10.6.tar.gz
[root@localhost /]# tar -xzvf /usr/local/src/v0.10.6.tar.gz -C /usr/local/nginx/module/

7、安装nginx sticky模块

[root@localhost /]# wget -P/usr/local/src/ https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/08a395c66e42.zip
[root@localhost /]# unzip -x nginx-goodies-nginx-sticky-module-ng-08a395c66e42.zip
[root@localhost /]# mv nginx-goodies-nginx-sticky-module-ng-08a395c66e42 /usr/local/nginx/module/nginx-sticky-module-1.2.5

 8、安装echo-nginx模块

[root@localhost /]# wget -P/usr/local/src/ https://github.com/openresty/echo-nginx-module/archive/echo-nginx-module-0.60.tar.gz
[root@localhost /]# tar -xzvf /usr/local/src/echo-nginx-module-0.60.tar.gz -C /usr/local/nginx/module/

9、安装ngx_cache_purge模块

[root@localhost /]# wget -P/usr/local/src/ https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz
[root@localhost /]# tar -xzvf /usr/local/src/ngx_cache_purge-2.3.tar.gz -C /usr/local/nginx/module/

10、安装ngx_http_lower_upper_case

[root@localhost /]# wget -P/usr/local/src/ https://github.com/replay/ngx_http_lower_upper_case/archive/master.zip
[root@localhost lib]# unzip -x ngx_http_lower_upper_case-master.zip
[root@localhost /]# mv ngx_http_lower_upper_case-master /usr/local/nginx/module/ ngx_http_lower_upper_case

 11、安装、配置Nginx

[root@localhost /]# wget -P/usr/local/src/ http://nginx.org/download/nginx-1.10.1.tar.gz
[root@localhost /]# tar -xzvf /usr/local/src/nginx-1.10.1.tar.gz -C /usr/local/src/
[root@localhost /]# cd /usr/local/src/nginx-1.10.1
[root@localhost nginx-1.10.1]# ./configure --prefix=/usr/local/nginx \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre=/usr/local/nginx/module/pcre-8.39 \
--with-zlib=/usr/local/nginx/module/zlib-1.2.8 \
--with-openssl=/usr/local/nginx/module/openssl-1.0.2h \
--add-module=/usr/local/nginx/module/lua-nginx-module-0.10.6 \
--add-module=/usr/local/nginx/module/nginx-sticky-module-1.2.5 \
--add-module=/usr/local/nginx/module/echo-nginx-module-0.60 \
--add-module=/usr/local/nginx/module/ngx_cache_purge-2.3 \
--add-module=/usr/local/nginx/module/ngx_http_lower_upper_case
[root@localhost nginx-1.10.1]# make
[root@localhost nginx-1.10.1]# make install

常见错误

# /usr/local/nginx-1.10.1/sbin/nginx -V

./objs/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

解决方法:

# ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

12、编译参数详解:

支持http_v2协议

--with-http_v2_module

 支持SSL加密 

--with-http_ssl_module

获取客户端真实IP  

--with-http_realip_module

查看Nginx服务器工作状态  

--with-http_stub_status_module

支持Rewrite重写规则 

--with-pcre=/usr/local/nginx/module/pcre-8.39

实现基于cookie的负载均衡 

--add-module=/usr/local/nginx/module/nginx-sticky-module-1.2.5

 用于从FastCGI、proxy、SCGI 和uWSGI缓存中增加内容清除功能 

--add-module=/root/ngx_cache_purge-2.1

 在Nginx配置中调用lua语言脚本

--add-module=/usr/local/nginx/module/lua-nginx-module-0.10.6

提供直接在 Nginx 配置使用包括 "echo", "sleep", "time" 等指令

--add-module=/usr/local/nginx/module/echo-nginx-module-0.60

 实现大小写字母转换

--add-module=/usr/local/nginx/module/ngx_http_lower_upper_case

 13、添加用户、设置权限目录

useradd nginx -s /sbin/nologin
chown -R nginx:nginx /usr/local/nginx
mkdir -p /home/cache/temp
mkdir -p /home/cache/path
chown -R nginx:nginx /home/cache
cd /usr/local/nginx/logs
mkdir p download v5api order user www www-null
mkdir /usr/local/nginx/conf/v5website
mkdir /usr/local/nginx/rootpath
mkdir /usr/local/nginx/ssl

14、TLSv1.2配置 

生成DH密钥

[root@localhost /]# cd /usr/local/nginx/ssl/
[root@localhost ssl]# openssl dhparam 4096 -out dhparam.pem

在nginx.conf文件中添加如下ssl相关的配置:

ssl_certificate /usr/local/nginx/ssl/17track.crt;
ssl_certificate_key /usr/local/nginx/ssl/17track.key
ssl_dhparam /usr/local/nginx/ssl/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

 

原文链接: https://www.cnblogs.com/configure/p/5619654.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Nginx 1.10.1 编译、配置文档(支持http_v2,TLSv1.2,openssl v1.0.2)

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/235965

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月13日 下午4:51
下一篇 2023年2月13日 下午4:52

相关推荐