如何在Lighttpd Server中配置SSL


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

所有使用SSL运行的站点都在默认端口443上使用了https协议。SSL通过加密服务器和客户端之间的数据来提供安全的数据通信。

在我们之前的文章中,我们已经介绍了如何在CentOS/RHEL系统中安装LightTPD和创建虚拟主机。本文将继续介绍在LightTPD服务器中配置SSL。对于本篇文章中的示例,我们使用的是自签名证书。

如果要在apache/httpd中查找configure ssl,那么可能需要阅读本篇文章。

步骤1:创建证书签名请求(CSR)

对于创建SSL证书,第一个要求是创建私钥和CSR。CSR是一个文件,其中包含有关域的所有详细信息,包括公钥。首先创建一个目录,在其中创建CSR和密钥。

1

2

# mkdir /etc/lighttpd/ssl/

# cd /etc/lighttpd/ssl/

现在使用以下命令创建CSR和密钥文件。根据域更改文件名example.com.key和example.com.csr。此命令将要求输入有关您的域的信息。了解有关创建CSR的更多信息。

1

# openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

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 Inc.

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

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

Email Address []:user@example.com

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []: [Leave Blank]

An optional company name []: [Leave Blank]

步骤2:从CA请求证书

创建CSR后,从任意证书提供商(如geotrust、comodo、digicert或godaddy等)请求一个SSL证书。

或创建供内部使用的自签名证书

1

# openssl x509 -req -days 365 -inexample.com.csr-signkeyexample.com.key-outexample.com.crt

将在名为example.com.crt的当前目录中获取创建的证书文件。现在通过将密钥文件和证书组合在一个文件中来创建pem文件

1

# cat example.com.key  example.com.crt > example.com.pem

步骤3:使用SSL设置虚拟主机

编辑lighttpd配置文件/etc/lighttpd/lighttpd.conf并添加以下值。

1

2

3

4

5

6

7

8

9

$SERVER["socket"] == ":443" {

        ssl.engine = "enable"

        ssl.pemfile = "/etc/lighttpd/ssl/tecadmin.net.pem"

      # ssl.ca-file = "/etc/lighttpd/ssl/CA_issuing.crt"

        server.name = "site1.tecadmin.net"

        server.document-root = "/sites/vhosts/site1.tecadmin.net/public"

        server.errorlog = "/var/log/lighttpd/site1.tecadmin.net.error.log"

        accesslog.filename = "/var/log/lighttpd/site1.tecadmin.net.access.log"

}

步骤4:验证配置并重新启动lighttpd

启动lighttpd服务之前,请验证配置文件的语法。

1

2

3

# lighttpd -t -f /etc/lighttpd/lighttpd.conf

 

Syntax OK

如果发现所有语法都正常,让我们重新启动服务。

1

# service lighttpd restart

【相关推荐:Linux视频教程】

以上就是如何在Lighttpd Server中配置SSL的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

如何在lighttpd server中配置ssl

nginx安装ssl证书的正确方法

nginx怎么配置ssl

如何在ubuntu 18.04和16.04 lts上设置let’s encrypt ssl

如何在lighttpd server中配置ssl

如何在ubuntu 18.04和16.04 lts上设置let’s encrypt ssl

apache支持ssl

nginx怎么增加ssl模块

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



打赏

取消

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

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

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

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

评论

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