Nginx配置SSL遇到的问题

今天早上想给自己的服务器添加ssl证书,上传证书,配置证书后发现nginx没有配置ssl_module,只好自行添加了

1
2
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# nginx -s reload
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:99

首先,需要重新编译源码

1
2
3
4
5
6
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# cd 
...
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
...
/maxec/runtime/installer/nginx-1.14.2/
root@instance-0vy61lkh:/maxec/runtime/installer/nginx-1.14.2# make

这一步千万不能 make install ;不然会把之前已经安装的nginx 覆盖掉
除非你已经备份了配置文件
如果中间发现缺少openssl库,可通过以下命令安装

1
2
sudo apt-get install openssl 
sudo apt-get install libssl-dev

现在,检查我们的安装是否生效

1
2
3
4
5
6
7
8
9
10
root@instance-0vy61lkh:/usr/local/nginx# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
root@instance-0vy61lkh:/usr/local/nginx/conf# /etc/init.d/nginx start
...
root@instance-0vy61lkh:/usr/local/nginx/conf# netstat -lnp|grep nginx
...

参考:
https://www.cnblogs.com/piscesLoveCc/p/6120875.html

-------------本文结束感谢您的阅读-------------