分类: 系统运维
2017-06-20 10:55:10
运行命令:
1、$ yum install openssl openssl-devel -y
2、$ openssl version
a)首先,进入你想创建证书和私钥的目录,例如:
$ cd /usr/local/nginx/conf/ssl
b)创建服务器私钥,命令会让你输入一个口令
$ openssl genrsa -des3 -out server.key 1024
c)创建签名请求的证书(CSR)
d)在加载SSL支持的并使用上述私钥时除去必须的口令
e)最后标记证书使用上述私钥和CSR
1、添加ssl模块
[root@fuhai-server sbin]#./nginx-V
nginx version:nginx/1.9.9
built by gcc 4.4.7 20120313(Red Hat 4.4.7-17)(GCC)
built with OpenSSL 1.0.1t 3 May 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src --with-pcre=/usr/local/pcre-8.39 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/local/openssl-1.0.1t --with-http_ssl_module
如果没有--with-http_ssl_module,则需要重新编译添加ssl模块
2、重新编译
[root@fuhai-server nginx-1.9.9]#./configure--prefix=/usr/local/nginx--add-module=/usr/local/fastdfs-nginx-module/src--with-pcre=/usr/local/pcre-8.39--with-zlib=/usr/local/zlib-1.2.8--with-openssl=/usr/local/openssl-1.0.1t--with-http_ssl_module
server {
server_name YOUR_DOMAINNAME_HERE;
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
}