如何在Apache中创建和安装自签名证书


本文摘自PHP中文网,作者不言,侵删。

SSL对于用户和Web服务器之间的安全通信很有用。证书在公共线路上传输时对数据进行加密,这样它就不会受到黑客的攻击。自签名证书是免费使用的,但不在生产环境中使用,例如使用信用卡、Paypal信息的机密数据。本篇文章将介绍关于在Linux系统上的Apache服务器中创建和安装自签名证书。

步骤1:安装mod_ssl包

要设置SSL证书,请确保在系统上安装了mod_ssl。如果尚未安装,需要使用以下命令进行安装。另外,安装openssl包来创建证书。

1

2

3

$ sudo apt-get install openssl          # Debian based systems

$ sudo yum install mod_ssl openssl      # Redhat / CentOS systems

$ sudo dnf install mod_ssl openssl      # Fedora 22+ systems

步骤2:创建自签名证书

安装mod_ssl和openssl后,使用以下命令为你的域创建一个自签名证书。

1

2

$ sudo mkdir -p /etc/pki/tls/certs

$ sudo cd /etc/pki/tls/certs

现在创建SSL证书

1

$ sudo openssl req -x509 -nodes -newkey rsa:2048 -keyout example.com.key -out example.com.crt

输出

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

Generating a 2048 bit RSA private key

....................................+++

...................................+++

writing new private key to 'example.com.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]: IN

State or Province Name (full name) []: Delhi

Locality Name (eg, city) [Default City]: Delhi

Organization Name (eg, company) [Default Company Ltd]: TecAdmin

Organizational Unit Name (eg, section) []: blog

Common Name (eg, your name or your server's hostname) []: www.example.com

Email Address []: admin@example.com

上面的命令将在当前目录中创建一个ssl密钥文件example.com.key和一个证书文件example.com.crt。

阅读剩余部分

相关阅读 >>

Apache能做反向代理吗

Apache启动之后怎么访问

ubuntu如何卸载Apache服务

linux Apache安装目录在哪

Apache怎么下载安装

解析如何在Apache服务器下设置url访问中文编码

Apache无法解析php文件怎么解决

Apache和tomcat有什么不同

Apache服务器启动方法

如何查看Apache的版本

更多相关阅读请进入《Apache》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...