2017年7月

nginxn编译需要openssl 1.0.2 版本很重要,很多文章都疏漏了,导致安装完后http2还是http1.1

wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar -zxvf openssl-1.0.2l.tar.gz
cd openssl-1.0.2l
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib-dynamic
make
make install

替换掉旧的openssl

32位

mv /usr/bin/openssl /usr/bin/openssl.old1
mv /usr/include/openssl /usr/include/openssl.old1
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl/ /usr/include/openssl
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
export LD_LIBRARY_PATH=/usr/local/openssl/lib
source /etc/profile

64位

mv /usr/bin/openssl /usr/bin/openssl.old1
mv /usr/include/openssl /usr/include/openssl.old1
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl/ /usr/include/openssl
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v
export LD_LIBRARY_PATH=/usr/local/ssl/lib
source /etc/profile

openssl version
OpenSSL 1.0.2l 25 May 2017

安装nginx

//wget http://nginx.org/download/nginx-1.9.12.tar.gz
http://nginx.org/download/nginx-1.10.2.tar.gz 新版

wget http://nginx.org/download/nginx-1.9.12.tar.gz
tar -zxvf nginx-1.9.12.tar.gz

cd nginx-1.9.12

./configure --prefix=/usr/local/nginx \
--user=www \
--group=www \
--with-mail \
--with-mail_ssl_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_dav_module \
--with-http_sub_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-pcre \
--with-openssl=/usr/tmp/openssl-1.0.2l 

源安装文件目录

make && make install