升级nginx以支持http2的方法

2019-10-17 17:53:46丽君

将文件中的.openssl去掉,就可以支持编译之后的openssl路径了

CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"
CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"
CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"

正式编译

 ./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 
 --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-stream 
 --with-stream_ssl_module 
 --with-http_slice_module 
 --with-mail 
 --with-mail_ssl_module 
 --with-file-aio 
 --with-http_v2_module 
 --with-openssl=/usr/local/openssl

修改nginx配置

listen 443 ssl http2;

出现的问题及解决

centos7下openssl version报错openssl: error while loading shared libraries: libssl.so.1.1

echo /usr/local/openssl/lib >> /etc/ld.so.conf # 将openssl编译路径的lib库加入到/etc/ld.so.conf
ldconfig -v|grep libssl  # 检查是否添加成功

nginx重启出现错误,nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed

ls -l /var/cache/nginx/client_temp#检查该文件夹是否存在和文件夹的权限
mkdir -p /var/cache/nginx/client_temp #文件夹不存在则生成文件夹
chown -R www-data:www-data /var/cache/nginx/client_temp # 将文件夹所有者和组改为nginx的运行用户,具体见nginx.conf

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。