Linux Nginx 配置 SSL 证书支持 HTTPS 访问(参考)

Posted 苏州城外的微笑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Nginx 配置 SSL 证书支持 HTTPS 访问(参考)相关的知识,希望对你有一定的参考价值。

由于之前(Linux nginx安装与配置(参考))已经安装好了 nginx 所以要重新下载包编译 ssl
1.停止运行 nginx

systemcrl stop nginx.service

2.下载 nginx

cd /home/download
wget http://nginx.org/download/nginx-1.4.4.tar.gz
tar -xvf nginx-1.4.4.tar.gz
cd nginx-1.4.4

3.尝试编译 ssl

./configure --prefix=/home/nginx --with-http_stub_status_module --with-http_ssl_module

这里如果出现以下错误说明未安装 openssl,需要先安装(第四步)再重新执行第三步编译

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

出现以下内容则编译成功

Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
+ jemalloc library is disabled

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx dso module path: "/usr/local/nginx/modules/"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

4.安装 openssl(出现上述错误执行)

yum -y install openssl openssl-devel

5.编译通过执行 make,不要进行 make install,否则就是覆盖安装

make

6.备份已经安装好的 nginx

cp /home/nginx/sbin/nginx /home/nginx/sbin/nginx.bak

7.将编译好的 nginx 覆盖原有的 nginx

cp /home/download/nginx-1.4.4/objs/nginx /home/nginx/sbin/

8.启动 nginx

systemcrl start nginx.service

9.访问已配置好的 https 页面查看

以上是关于Linux Nginx 配置 SSL 证书支持 HTTPS 访问(参考)的主要内容,如果未能解决你的问题,请参考以下文章

linux系统自签发免费ssl证书,为nginx生成自签名ssl证书

nginx配置免费ssl证书支持https安全访问

linux nginx ssl证书怎么配置

配置http和tcp支持ssl

Swoole配置ssl(支持wss)

nginx开启ssl配置https证书和密钥过程