为了使系统支持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/
|
作者:虚生 出处:https://www.cnblogs.com/dylancao/ 以音频和传感器算法为核心的智能可穿戴产品解决方案提供商 ,提供可穿戴智能软硬件解决方案的设计,开发和咨询服务。 勾搭热线:邮箱:1173496664@qq.com weixin:18019245820 市场技术对接群:347609188 |
|
浙公网安备 33010602011771号