1.查看是否已经安装 ssl 组件

[root@localhost wwwlogs]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.0.15
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52)
TLS SNI support disabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
如果已经有了 http_ssl_module 则表示已经安装.若没有, 则要重新编译一安装 nginx
 
2.生成 key
[root@localhost sbin]# cd /usr/local/nginx/conf/
[root@localhost conf]# openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
.......++++++
..........................................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:abcd
Verifying - Enter pass phrase for server.key:abcd
 
3.生成证书
[root@localhost conf]# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:abcd
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:CN
State or Province Name (full name) [Berkshire]:beijing
Locality Name (eg, city) [Newbury]:chaoyang
Organization Name (eg, company) [My Company Ltd]:test
Organizational Unit Name (eg, section) []:web
Common Name (eg, your name or your server's hostname) []:sunyu
Email Address []:sunyu@test.cn
 
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:1qazxsw23edc
An optional company name []:testcomp
 
[root@localhost conf]# cp server.key server.key.org
[root@localhost conf]# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:abcd
writing RSA key
[root@localhost conf]# openssl x509 -req -days 365 -in server.csr -signkey server.key -outserver.crt
Signature ok
subject=/C=CN/ST=beijing/L=chaoyang/O=easymobi/OU=web/CN=sunyu/emailAddress=sunyu@easymobi.cn
Getting Private key
 
4.配置 nginx
在配置文件中加入:
server
{
listen       443;
server_name test.test.cn;
index index.html index.htm index.php;
root  /home/wwwroot/vegtest/;
 
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
}
然后访问 https://test.test.cn 即可看到效果.

centos nginx install openssl的更多相关文章

  1. Centos7 编译安装 Nginx Mariadb Asp.net Core2 (实测 笔记 Centos 7.3 + Openssl 1.1.0h + Mariadb 10.3.7 + Nginx 1.14.0 + Asp.net. Core 2 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  2. Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Openssl 1.1.0e + Mariadb 10.1.22 + Nginx 1.12.0 + PHP 7.1.4 + Laravel 5.4 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  3. CentOS 6.6 nginx install

    /************************************************************************* * CentOS 6.6 nginx instal ...

  4. nginx反向代理cas-server之2:生成证书,centOS下使用openssl生成CA证书(根证书、server证书、client证书)

    前些天搭好了cas系统,这几天一致再搞nginx和cas的反向代理,一直不成功,但是走http还是测试通过的,最终确定是ssl认证证书这一块的问题,原本我在cas服务端里的tomcat已经配置了证书, ...

  5. centos+nginx从零开始配置负载均衡

    nginx负载均衡的理解 nginx是一个轻量级的.高性能的webserver,他主要可以干下面两件事: 作为http服务器(和apache的效果一样) 作为反向代理服务器实现负载均衡 现在nginx ...

  6. CentOS+Nginx一步一步开始配置负载均衡

    Nginx负载均衡的理解 http://www.linuxdiyf.com/linux/10205.html Nginx是一个轻量级的.高性能的WebServer,他主要可以干下面两件事: 作为htt ...

  7. Nginx Install 记录

    一.安装编译工具及库文件 yum -y install gcc yum -y install gcc-c++ yum -y install zlib; yum -y install pcre-deve ...

  8. CentOS+Nginx+PHP 前端部署

    都说Nginx比Apache性能优越,一直没有时间装测试,今天终于有时间装上试试性能了,其实Nginx的安装非常简单,具体流水步骤记录如下: 1.系统环境: ===================== ...

  9. Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建)

    Cacti监控服务器配置教程(基于CentOS+Nginx+MySQL+PHP环境搭建) 具体案例:局域网内有两台主机,一台Linux.一台Windows,现在需要配置一台Cacti监控服务器对这两台 ...

随机推荐

  1. POJ 1364 King

    http://poj.org/problem?id=1364 题意 :给出一个序列a1,a2,a3,a4.....ai,......at ;然后给你一个不等式使得ai+a(i+1)+a(i+2)+.. ...

  2. Lua 笔记

    lua命令: #enter shell lua #excute script file lua xxx.lua lua脚本: #!/usr/local/bin/lua 核心概念: As a exten ...

  3. MongoDB实战指南(七):MongoDB复制集之复制集工作机制

    http://www.cnblogs.com/longshiyVip/p/5097336.html 概述了复制集,整体上对复制集有了个概念,但是复制集最重要的功能之——自动故障转移是怎么实现的呢?数据 ...

  4. ZOJ - 2615 Cells

    注意数组别开太小了,代码照着训练经典打的: #include <iostream> #include <sstream> #include <cstdio> #in ...

  5. char 和 varchar

    固定长度或可变长度的字符数据类型. char [ ( n ) ] 固定长度,非 Unicode 字符数据,长度为 n 个字节.n 的取值范围为 1 至 8,000,存储大小是 n 个字节.char 的 ...

  6. 通过Hibernate将数据库在myeclipse中逆向生成

    1.首先准备好数据库. 2.在MyEclipse的右上角切换透视图,切换到MyEclipse Database Explorer 3.在最左边点击右键,选择New(也就是新建一个数据库连接),然后编写 ...

  7. Android Root原理

    概述:通过阅读本文可以深刻理解Android系统中获得Root权限的方法和原理.本文会详细介绍Root的目的,原理和代码层次的具体实现方法. Android Root介绍: 1. Root目的 手机获 ...

  8. Xcode 不提示, 引用失效等情况

    在编写xcode的项目的时候出现过代码不高亮的症状,而且所有的warning都不再提示,include的内容也显示symbol not found,非常奇怪,解决方案如下: 方法一: 1.把.pch里 ...

  9. CSS3中动画属性transform、transition 和 animation

    CSS3中和动画有关的属性有三个 transform.transition 和 animation.下面来一一说明:        transform   从字面来看transform的释义为改变,使 ...

  10. [转]NHibernate之旅(13):初探立即加载机制

    本节内容 引入 立即加载 实例分析 1.一对多关系实例 2.多对多关系实例 结语 引入 通过上一篇的介绍,我们知道了NHibernate中默认的加载机制——延迟加载.其本质就是使用GoF23中代理模式 ...