nginx-tengine 编译http2 tls1.3


在开始编译之前,需要确保已经安装好编译工具

debian系需要安装

apt-get install libtool gcc g++
apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip uuid-dev

redhat系需要安装

yum -y install gcc-c++

随后编译并安装 pcre,用于支持 rewrite

redhat系需要安装

yum -y install pcre-devel openssl openssl-devel

或手动编译pcre

cd /usr/local/src
wget https://ftp.pcre.org/pub/pcre/pcre-8.44.zip
unzip pcre-8.44.zip
cd pcre-8.44
./configure
make && make install

编译并安装 zlib,用于支持 gzip

cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install

然后我们下载 openssl 源码为编译 Nginx 做准备,打开这个链接后点击当前最新的版本 “OpenSSL_1_1_1” 下面的 hash 值,在页面中复制完整的 hash ,稍后需要用到。
在最后一步中,填入你所复制的 hash。这里我们不需要编译 openssl ,随后在编译 Nginx 时会顺带处理

cd /usr/local/src
git clone https://github.com/openssl/openssl.git
cd openssl
git checkout 1d864f0f534fe38541c7adba5777935a0f2a2eb9

编译nginx

cd /usr/local/src
wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
tar -zxvf tengine-2.3.2.tar.gz
cd tengine-2.3.2
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=www-data --group=www-data --with-openssl-opt=enable-ec_nistp_64_gcc_128 --with-pcre --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module

make && make install
mkdir /var/cache/nginx

然后配置nginx文件

cd /etc/nginx
include /etc/nginx/sites-enabled/*;
mkdir sites-enabled

创建配置文件

cd /etc/nginx/sites-enabled
vi mysite.conf

输入命令nginx -t检查配置文件
输入命令nginx启动
开机自动启动设置:在/etc/rc.local 添加nginx