博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nginx 1.10.1 编译、配置文档(支持http_v2,TLSv1.2,openssl v1.0.2)
阅读量:7081 次
发布时间:2019-06-28

本文共 5140 字,大约阅读时间需要 17 分钟。

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/nologinchown -R nginx:nginx /usr/local/nginxmkdir -p /home/cache/tempmkdir -p /home/cache/pathchown -R nginx:nginx /home/cachecd /usr/local/nginx/logsmkdir p download v5api order user www www-nullmkdir /usr/local/nginx/conf/v5websitemkdir /usr/local/nginx/rootpathmkdir /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.keyssl_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

你可能感兴趣的文章
排序规则引起的冲突问题
查看>>
我的友情链接
查看>>
onTouch事件传递机制
查看>>
那些年的坑--双精度数值转成整形
查看>>
office 2007各种格式附件下载后变成zip文件问题解决方法
查看>>
宽依赖、窄依赖
查看>>
好程序员web前端系列之CSS3-3D
查看>>
xm 命令详解
查看>>
HttpClient4.x send json request
查看>>
mysql5.6基于GTID的主从复制
查看>>
iOS 获取Wifi的SSID及MAC地址
查看>>
认识六个被误解的Ruby特性
查看>>
Java线程:并发协作-生产者消费者模型
查看>>
libvirt API非阻塞调用及相关的原理分析
查看>>
老男孩第十四期Python学习班之Day06
查看>>
更改sql 数据库 SA密码 找不到sp_password存储过程
查看>>
破解软件注册码
查看>>
使用iptables应对SYN***、CC***、ACK***
查看>>
NO.9 用禅道项目管理软件创建第一个产品
查看>>
2013年10月15日星期二——java web 环境搭建(MySQL)
查看>>