在配置反向代理到 https的网站时,编辑配置文件报错,无法启动nginx,一番google之后,才知道是当初编译的时候没有启用SSL支持。
1、查看nginx编译安装时安装了哪些模块
# cd /data/software/nginx-1.12.2
# ./sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
configure arguments: --prefix=/data/software/nginx-1.12.2 --with-stream
可以看出编译安装使用了--prefix=/data/software/nginx-1.12.2 --with-stream这些参数
2. 加入需要安装的模块,重新编译,如这里添加--add-module=with-http_ssl_module:
# ./configure --prefix=/data/software/nginx-1.12.2 --with-stream --with-http_ssl_module
# make //千万不要make install,不然就真的覆盖了
3. 替换nginx二进制文件:
备份原来的nginx二进制文件
# cp ./sbin/nginx ./sbin/nginx.bak
拷贝新的nginx二进制文件到sbin目录下
cp ./objs/nginx ./sbin/
cp: overwrite ‘sbin/nginx’? y
cp: cannot create regular file ‘sbin/nginx’: Text file busy
遇到这个问题,先停止nginx进程
# ./sbin/nginx -s stop
然后再拷贝:
# cp objs/nginx sbin/
cp: overwrite ‘sbin/nginx’? y
查看已安装模块:
# ./sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/data/software/nginx-1.12.2 --with-stream --with-http_ssl_module
4.再配置反向代理到https的网站时,启动nginx成功!
参考:http://coolnull.com/4245.html
https://blog.csdn.net/zx1323/article/details/78934350