继在ubuntu 中搭建完成nginx后,下面继续记录如何配置https,我根据阿里云的教程,但是有一些关键的细节,花费了不少时间才完成的配置,因为之前安装nginx的时候,没有开启SSL模块,所以,需要找到源文件/root/webapp/tools/nginx/nginx-1.11.3重新加入SSL模块,进入nginx的源文件,运行/usr/local/nginx/sbin/nginx -V命令查看开启的模块,如果输出显示只有./configure --prefix=/usr/local/nginx,那就说明没有开启SSL模块,重新配置开启模块具体命令如下
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
在执行以上命令是,会报以下错误:
the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37
原因是nginx缺少http_ssl_module模块,编译安装时带上--with-http_ssl_module配置就可以了。
如果出现下图报错,那就执行 sudo apt-get install openssl libssl-dev进行安装openssl 依赖包,这只是Ubuntu的安装命令,centOS的安装命令是yum -y install openssl openssl-devel