安装openssl
cd /root
wget https://www.openssl.org/source/openssl-1.1.0c.tar.gz
tar -zxf openssl-1.1.0c.tar.gz
cd openssl-1.1.0c
./config
make
make install
#把旧版本的openssl重命名
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
#设置软连接指向刚编译好的新版本的openssl-1.1.0c
ln -s /usr/local/bin/openssl /usr/bin/openssl
ln -s /usr/local/include/openssl /usr/include/openssl
#如果是1.0.2h版本 生成的文件的位置在/usr/local/ssl
#添加libssl.so.1.1的软链接
ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
#查看openssl版本
openssl version
平滑升级nginx到最新的稳定版
查看现在的nginx版本和编译参数
root@ip-192-168-2-161:~/nginx-1.10.2# nginx -V
nginx version: nginx/1.4.6 (Ubuntu)
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
升级步骤
cd /root
wget http://nginx.org/download/nginx-1.17.2.tar.gz
#解压源码
tar zxvf nginx-1.17.2.tar.gz
#进入源码目录
cd nginx-1.17.2
#加上所需参数开始编译
# 根据上面的配置 with-http_spdy_module,修改为 --with-file-aio --with-http_v2_module(直接用上面的配置会报错)
./configure --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-file-aio --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
在执行./configure 会出现依赖库的问题
# pcre
sudo apt-get install libpcre3 libpcre3-dev
# GD
sudo apt-get install libgd2-xpm-dev or apt-get install libgd2-xpm libgd2-xpm-dev
apt-get install libgeoip-dev
#执行make编译,但是不要执行make install
make
#重命名nginx旧版本二进制文件,即sbin目录下的nginx(期间nginx并不会停止服务)
mv /usr/sbin/nginx /usr/sbin/nginx.old
#然后拷贝一份新编译的二进制文件
cp objs/nginx /usr/sbin/
#在源码目录执行make upgrade开始升级
make upgrade
会出现下面的错误
make: /etc/nginx/sbin/nginx: Command not found
make: *** [upgrade] Error 127
# 用文本编辑器打开修改nginx-1.2.5目录下名为Makefile的文件,将upgrade节点中的/etc/nginx/sbin/nginx改为/usr/sbin/nginx -t,保存后关闭并重新执行make upgrade命令
升级完成后会显示
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/share/nginx"
nginx binary file: "/usr/share/nginx/sbin/nginx"
nginx modules path: "/usr/share/nginx/modules"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/scgi"
./configure: warning: the "--with-ipv6" option is deprecated
配置http2.0
配置Nginx开启http 2.0特别简单,只要在Nginx配置文件中找到你要开启http2.0的域名server模块,然后将 listen 443 ssl;改成 listen 443 ssl http2; 即可。
网友评论