登录  /  注册
首页 > 运维 > linux运维 > 正文
如何在Lighttpd Server中配置SSL
不言
发布: 2019-04-01 16:31:59
原创
2553人浏览过

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

如何在Lighttpd Server中配置SSL

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

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

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

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

# mkdir /etc/lighttpd/ssl/
# cd /etc/lighttpd/ssl/
登录后复制

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

# openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr
登录后复制
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证书。

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

# openssl x509 -req -days 365 -inexample.com.csr-signkeyexample.com.key-outexample.com.crt
登录后复制

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

# cat example.com.key  example.com.crt > example.com.pem
登录后复制

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

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

$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服务之前,请验证配置文件的语法。

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

Syntax OK
登录后复制

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

# service lighttpd restart
登录后复制

【相关推荐:Linux视频教程

以上就是如何在Lighttpd Server中配置SSL的详细内容,更多请关注php中文网其它相关文章!

相关标签:
SSL
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 技术文章
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2023 //m.sbmmt.com/ All Rights Reserved | 苏州跃动光标网络科技有限公司 | 苏ICP备2020058653号-1

 | 本站CDN由 数掘科技 提供

登录PHP中文网,和优秀的人一起学习!
全站2000+教程免费学