在Ubuntu上部署SSL证书通常涉及以下几个步骤:
获取SSL证书:
安装Web服务器(如果你还没有的话):
sudo apt update
sudo apt install apache2
配置Web服务器:
sudo a2enmod ssl
sudo systemctl restart apache2
上传证书文件:
.crt
或.pem
格式)和私钥文件(通常是.key
格式)上传到服务器上的安全位置。配置SSL证书:
/etc/apache2/sites-available/default-ssl.conf
),并指定证书和私钥的路径。<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateFile /path/to/your/certificate.crt
SSLCertificateKeyFile /path/to/your/private.key
SSLCertificateChainFile /path/to/your/ca_bundle.crt
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/nginx/sites-available/yourdomain.com
),并添加SSL配置。server {
listen 443 ssl;
server_name yourdomain.com www.yourdomain.com;
ssl_certificate /path/to/your/certificate.crt;
ssl_certificate_key /path/to/your/private.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256...';
root /var/www/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
ErrorLog ${APACHE_LOG_DIR}/error.log;
CustomLog ${APACHE_LOG_DIR}/access.log combined;
}
重载Web服务器:
sudo systemctl reload apache2
sudo systemctl reload nginx
测试SSL配置:
请注意,这些步骤可能会根据你的具体需求和服务器配置有所不同。确保在部署SSL证书时遵循最佳实践,以保证你的网站和用户数据的安全。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: 虚拟机ubuntu如何使用GPU加速