1. 启用 ssl 模块
- sudo a2enmod ssl
2. 安装openssl
- sudo apt-get install openssl
3. 创建CA签名(不使用密码去除-des3选项)
- openssl genrsa -des3 -out server.key 1024
4. 创建CSR(Certificate Signing Request)
- openssl req -new -key server.key -out server.csr
5. 自己签发证书
- openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
6. 复制到相应目录
- sudo cp server.crt /etc/ssl/certs
- sudo cp server.key /etc/ssl/private
7. 修改配置文件
- sudo cp /etc/apache2/sites-enabled/000-default /etc/apache2/sites-enabled/001-ssl
- sudo vim 001-ssl
在<VirtualHost *:80>段中,DocumentRoot一行的下方加入内容:
- SSLEngine On
- SSLOptions +StrictRequire
- SSLCertificateFile /etc/ssl/certs/server.crt
- SSLCertificateKeyFile /etc/ssl/private/server.key
端口修改为:443,即<VirtualHost *:443>(ssl的端口)
8. 重启apache
- sudo /etc/init.d/apache2 force-reload
- sudo /etc/init.d/apache2 restart
原文地址:https://www.cnblogs.com/orangezs/p/8327652.html
时间: 2024-11-08 19:54:54