1、安装openssl
yum install openssl openssl-devel -y
2、创建证书目录
mkdir /etc/nginx/ssl_key
3、进入目录
cd /etc/nginx/ssl_key
4、输入密码,创建私钥文件,至少4位
[root@web-7 /etc/nginx/ssl_key]#openssl genrsa -idea -out server.key2048
Generating RSA privatekey, 2048 bit long modulus
...................................+++
.............+++
e is65537 (0x10001)
Enter pass phrase for server.key:afei11
Verifying - Enter pass phrase for server.key:afei11
填写证书文件
[root@web-7 /etc/nginx/ssl_key]#openssl req -days 36500 -x509 -sha256 -nodes -newkey rsa:2048 -keyout server.key -out server.crt
Generating a 2048 bit RSA privatekey
............................................................................................................................+++
..................................................................................+++
writing newprivatekeyto'server.key'
-----
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) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:afeitt.cn
Organizational Unit Name (eg, section) []:afeitt.cn
Common Name (eg, your name or your server's hostname) []:afeitt.cn
Email Address []:1398787859@qq.com
分别填入证书的信息
国家
省份
城市
组织
部门
主机名
邮箱
查看公私钥和证书
[root@web-7 /etc/nginx/ssl_key]#ls
server.crt server.key
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?