nginx添加https模块

https://blog.csdn.net/buyueliuying/article/details/89676892

https://blog.csdn.net/CSDNOfWK/article/details/78433962

------------------------------------------------------------------

总结:

1、查看是否安装

     /usr/local/nginx/sbin/nginx -V

2、cd /nginx-1.10.3

3、./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-openssl=/java/openssl-1.1.0 --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-stream

./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-openssl=/java/openssl-1.1.1c --with-stream

 

注意:使用--with-openssl=<openssl_dir>  /java/openssl-1.1.0为openssl解压目录

4、make

5、备份原来的nginx

6、停止启动的nginx

7、覆盖:cp /java/nginx-1.10.1/objs/nginx /usr/local/nginx/sbin/

8、启动nginx

总结一下:其实,最关键的一步就是覆盖掉原来的nginx, 可以从别的服务器上复制过来,就可以了

-------------------------------------------------------------------

nginx需要安装ssl模块来使用https

查看nginx版本与编译安装了哪些模块

/usr/local/nginx/sbin/nginx -V
1
如果没有看到 ‘OpenSSL’等字眼说明还没安装ssl模块,继续下面的操作

添加模块(非覆盖安装)

切换到你的nginx安装包解压目录下

cd /nginx-1.10.3
1
使用参数重新配置

./configure --with-http_stub_status_module --with-http_ssl_module
1
其中 --with-http_ssl_module 就是ssl模块

编译

make
1
不要使用make install指令,否则就是覆盖安装。
替换nginx二进制文件:

cp ./objs/nginx /usr/local/nginx/sbin/
1
如果覆盖过程中提示‘cp: 无法创建普通文件"/usr/local/nginx/sbin/nginx": 文本文件忙’ ,说明nginx在运行中,先暂停nginx服务。

至此,ssl模块已成功添加

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

编译安装nginx的坑
报错信息
make -f objs/Makefile
make[1]: Entering directory `/data/source/nginx'
cd /usr/local/ufo/lib/pcre \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared
/bin/sh: ./configure: No such file or directory
make[1]: *** [/usr/local/services/lib/pcre/Makefile] Error 127
make[1]: Leaving directory `/data/source/nginx-0.7.61'
make: *** [build] Error 2
1
2
3
4
5
6
7
8
9
10
11
分析
一开始一点儿头绪都没有,上网查发现是少了pcre和zlib的包,后来添加上nginx自带的两个目录。./configure过了,但是make编译又出错,说是没找到pcre,但是我明明用–with-pcre=/pcre/home指定了啊,查来查去发现要指定源码目录。我用yum安装的pcre包,找了一下没找到源码啊,网上的博客也都是抄来抄去没解决我的问题,后来我就想没有那就下个源码包好了。就用下面两个命令下载好,解压好。终于编译通过。

wget https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
wget https://jaist.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
1
2
启动nginx发现外网访问无响应,才想起来防火墙没关,关掉防火墙访问,终于看到期待的画面。

posted on 2021-10-09 16:21  四海骄阳  阅读(437)  评论(0编辑  收藏  举报

导航