linux下安装nginx 免费ssl证书申请   Nginx配置SSL证书部署https支持 补充 转换pfx为nginx需要的crt,key 参考文献

linux系统为Centos 64位

第一步:从http://nginx.org/download/上下载相应的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载)

第二步:解压 tar -zxvf nginx-1.5.9.tar.gz 

第三步:设置一下配置信息 ./configure --prefix=/usr/local/nginx ,或者不执行此步,直接默认配置

第四步:

make 编译 (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)

make install 安装 (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)

在配置信息的时候,也就是在第三步,出现了一下错误:

linux下安装nginx
免费ssl证书申请
 
Nginx配置SSL证书部署https支持
补充
转换pfx为nginx需要的crt,key
参考文献

错误为:./configure: error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

还有可能出现:

错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

解决办法:

yum -y install openssl openssl-devel

安装后在linux下启动和关闭nginx:

启动操作

/usr/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正确)

 
停止操作
停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的
步骤1:查询nginx主进程号
ps -ef | grep nginx
在进程列表里 面找master进程,它的编号就是主进程号了。
步骤2:发送信号
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 nginx

另外, 若在nginx.conf配置了pid文件存放路径则该文件存放的就是Nginx主进程号,如果没指定则放在nginx的logs目录下。有了pid文 件,我们就不用先查询Nginx的主进程号,而直接向Nginx发送信号了,命令如下:
kill -信号类型 '/usr/nginx/logs/nginx.pid'

平滑重启
如果更改了配置就要重启Nginx,要先关闭Nginx再打开?不是的,可以向Nginx 发送信号,平滑重启。
平滑重启命令:
kill -HUP 住进称号或进程号文件路径

或者使用

/usr/nginx/sbin/nginx -s reload

注意,修改了配置文件后最好先检查一下修改过的配置文件是否正 确,以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf

或者

/usr/nginx/sbin/nginx -t
 
如下图:
linux下安装nginx
免费ssl证书申请
 
Nginx配置SSL证书部署https支持
补充
转换pfx为nginx需要的crt,key
参考文献
转自:http://www.cnblogs.com/kunhu/p/3633002.html
 

到 http://www. wosign.com /Products/free_SSL.htm 申请免费的SSL证书。

下载www.iamle.com.zip文件,解压文件,找到for Nginx.zip解压,得到2个文件

1_www.iamle.com_bundle.crt ,2_www.iamle.com.key

改个名字www.iamle.com.crt,www.iamle.com.key传到服务器上备用

 

Nginx配置SSL证书部署https支持

找到对应的server

增加

 
 
 
 
 
Shell
 
1
2
3
4
5
6
7
8
listen          443 ssl;
ssl                     on;
ssl_certificate         /usr/local/nginx/conf/ssl/www.iamle.com.crt;
ssl_certificate_key     /usr/local/nginx/conf/ssl/www.iamle.com.key;
ssl_session_timeout     5m;
ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers             ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers       on;

重新载入nginx配置

[root@do ssl]# /etc/init.d/nginx  reload

浏览器信任的https://www.iamle.com 已经可用了~

补充

转换pfx为nginx需要的crt,key

如果已经有一个扩展名为pfx的证书,那么需要转换使用

 
 
 
 
 
Shell
 
1
2
3
4
5
6
7
8
9
[root@do ~]# openssl pkcs12 -in www.iamle.com.pfx -nocerts -nodes -out www.iamle.com.key
Enter Import Password: 输入证书密码
MAC verified OK
 
 
 
[root@do ~]# openssl pkcs12 -in www.iamle.com.pfx -clcerts -nokeys -out www.iamle.com.crt
Enter Import Password: 输入证书密码
MAC verified OK

生成2个文件 www.iamle.com.key , www.iamle.com.pfx 复制到你指定的目录

参考文献

http://nginx.org/en/docs/http/configuring_https_servers.html

第一步:从http://nginx.org/download/上下载相应的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载)

第二步:解压 tar -zxvf nginx-1.5.9.tar.gz 

第三步:设置一下配置信息 ./configure --prefix=/usr/local/nginx ,或者不执行此步,直接默认配置

第四步:

make 编译 (make的过程是把各种语言写的源码文件,变成可执行文件和各种库文件)

make install 安装 (make install是把这些编译出来的可执行文件和库文件复制到合适的地方)

在配置信息的时候,也就是在第三步,出现了一下错误:

linux下安装nginx
免费ssl证书申请
 
Nginx配置SSL证书部署https支持
补充
转换pfx为nginx需要的crt,key
参考文献

错误为:./configure: error: the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题
yum -y install pcre-devel

还有可能出现:

错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

解决办法:

yum -y install openssl openssl-devel

安装后在linux下启动和关闭nginx:

启动操作

/usr/nginx/sbin/nginx (/usr/nginx/sbin/nginx -t 查看配置信息是否正确)

 
停止操作
停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的
步骤1:查询nginx主进程号
ps -ef | grep nginx
在进程列表里 面找master进程,它的编号就是主进程号了。
步骤2:发送信号
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 nginx

另外, 若在nginx.conf配置了pid文件存放路径则该文件存放的就是Nginx主进程号,如果没指定则放在nginx的logs目录下。有了pid文 件,我们就不用先查询Nginx的主进程号,而直接向Nginx发送信号了,命令如下:
kill -信号类型 '/usr/nginx/logs/nginx.pid'

平滑重启
如果更改了配置就要重启Nginx,要先关闭Nginx再打开?不是的,可以向Nginx 发送信号,平滑重启。
平滑重启命令:
kill -HUP 住进称号或进程号文件路径

或者使用

/usr/nginx/sbin/nginx -s reload

注意,修改了配置文件后最好先检查一下修改过的配置文件是否正 确,以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf

或者

/usr/nginx/sbin/nginx -t
 
如下图:
linux下安装nginx
免费ssl证书申请
 
Nginx配置SSL证书部署https支持
补充
转换pfx为nginx需要的crt,key
参考文献
转自:http://www.cnblogs.com/kunhu/p/3633002.html
 

到 http://www. wosign.com /Products/free_SSL.htm 申请免费的SSL证书。

下载www.iamle.com.zip文件,解压文件,找到for Nginx.zip解压,得到2个文件

1_www.iamle.com_bundle.crt ,2_www.iamle.com.key

改个名字www.iamle.com.crt,www.iamle.com.key传到服务器上备用

 

Nginx配置SSL证书部署https支持

找到对应的server

增加

 
 
 
 
 
Shell
 
1
2
3
4
5
6
7
8
listen          443 ssl;
ssl                     on;
ssl_certificate         /usr/local/nginx/conf/ssl/www.iamle.com.crt;
ssl_certificate_key     /usr/local/nginx/conf/ssl/www.iamle.com.key;
ssl_session_timeout     5m;
ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers             ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers       on;

重新载入nginx配置

[root@do ssl]# /etc/init.d/nginx  reload

浏览器信任的https://www.iamle.com 已经可用了~

补充

转换pfx为nginx需要的crt,key

如果已经有一个扩展名为pfx的证书,那么需要转换使用

 
 
 
 
 
Shell
 
1
2
3
4
5
6
7
8
9
[root@do ~]# openssl pkcs12 -in www.iamle.com.pfx -nocerts -nodes -out www.iamle.com.key
Enter Import Password: 输入证书密码
MAC verified OK
 
 
 
[root@do ~]# openssl pkcs12 -in www.iamle.com.pfx -clcerts -nokeys -out www.iamle.com.crt
Enter Import Password: 输入证书密码
MAC verified OK

生成2个文件 www.iamle.com.key , www.iamle.com.pfx 复制到你指定的目录

参考文献

http://nginx.org/en/docs/http/configuring_https_servers.html