openssl编译安装

tar -zxvf openssl-1.0.2l.tar.gz 
./config --prefix=/usr/local/openssl
#注意如果有问题,会显示出来,一般是perl版本问题
make && make install
#重命名原来的openssl命令
mv /usr/bin/openssl /usr/bin/openssl.old
#重命名原来的openssl目录
mv /usr/include/openssl /usr/include/openssl.old
#将安装好的openssl 的openssl命令软连到/usr/bin/openssl
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
#将安装好的openssl 的openssl目录软连到/usr/include/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
#修改系统自带的openssl库文件,如/usr/local/lib64/libssl.so(根据机器环境而定) 软链到升级后的libssl.so
ln -s /usr/local/ssl/lib/libssl.so /usr/local/lib64/libssl.so
#执行命令查看openssl依赖库版本是否为1.0.1g:
strings /usr/local/lib64/libssl.so |grep OpenSSL
#在/etc/ld.so.conf文件中写入openssl库文件的搜索路径
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
#使修改后的/etc/ld.so.conf生效
ldconfig -v

nginx编译安装

/usr/local/nginx/sbin/nginx -V
cd /opt/nginx-1.14.0
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf --http-log-path=/usr/local/nginx/log/access.log --error-log-path=/usr/local/nginx/log/error.log --lock-path=/usr/lcoal/nginx/log/nginx.lock --pid-path=/usr/local/nginx/nginx.pid --http-client-body-temp-path=/usr/local/nginx/body --http-fastcgi-temp-path=/usr/local/nginx/fastcgi --http-proxy-temp-path=/usr/local/nginx/proxy --http-scgi-temp-path=/usr/local/nginx/scgi --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module  --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --with-openssl=/usr/local/openssl
make
#千万别make install,否则就覆盖安装了
cp /usr/local/nginx/sbin/nginx  /usr/local/nginx/sbin/nginx.bak
ps -ef |grep nginx
#查看master进程号XX
kill -QUIT  XXX
cp /opt/nginx-1.14.0/objs/nginx /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx


make的时候编译报错了,参考以下方法解决

[/usr/local/openssl//.openssl/include/openssl/ssl.h] Error 127

openssl升级1.0.2k及nginx1.14.0编译安装-LMLPHP
解决Nginx添加openssl模块编译时报错问题   

/bin/sh: line 2: ./config: No such file or directory
make[1]: *** [/usr/local/ssl/.openssl/include/openssl/ssl.h] Error 127
make[1]: Leaving directory `/usr/local/src/nginx-1.9.9'
make: *** [build] Error 2

/ssl/这个目录可以发现这个目录下是没有.openssl目录的,因此我们修改Nginx编译时对openssl的路径选择就可以解决这个问题了

解决方案:
打开nginx源文件下的/usr/local/src/nginx-1.9.9/auto/lib/openssl/conf文件:
找到这么一段代码:
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"

CORE_LIBS="$CORE_LIBS $NGX_LIBDL"

修改成以下代码:

CORE_INCS="$CORE_INCS $OPENSSL/include"

CORE_DEPS="$CORE_DEPS $OPENSSL/include/openssl/ssl.h"

CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libssl.a"

CORE_LIBS="$CORE_LIBS $OPENSSL/lib/libcrypto.a"

CORE_LIBS="$CORE_LIBS $NGX_LIBDL"

 然后再进行Nginx的编译安装即可

09-01 22:33