Fork me on GitHub

随笔 - 997  文章 - 5  评论 - 181  阅读 - 300万 

  为了使系统支持https模式,首先我们要使能ssl模式。

命令如下:

sudo a2enmod ssl
sudo systemctl restart apache2

  接下来我们要生成一个SSL/TLS 认证,下面的命令就是产生一个TLS命令并且生成一个私钥:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/example.com.key -out /etc/ssl/certs/example.com.crt

  应用SSL签名:  

  创建一个虚拟的Host 文件,在目录下 /etc/apache2/site-available 的(e.g. example.com-ssl.conf) 具体配置信息:

复制代码
<VirtualHost *:443>
    ServerName www.example.com
    ServerAlias example.com
    DocumentRoot /var/www/example.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/example.com.crt
    SSLCertificateKeyFile /etc/ssl/private/example.com.key
</VirtualHost>
复制代码

  最后,使能https并且重启Apache服务。

sudo a2ensite example.com-ssl.conf
sudo systemctl reload apache2

 

 

参考文档:

1 https://www.configserverfirewall.com/hosting/openssl-ubuntu-self-signed-certificate/

posted on   虚生  阅读(1346)  评论(0编辑  收藏  举报
编辑推荐:
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
历史上的今天:
2017-11-25 Ubuntu下几个命令行方式使用的图片浏览工具
点击右上角即可分享
微信分享提示