1 頁 (共 1 頁)

安裝 apache let's encrypt ssl 憑證

發表於 : 2026-04-10, 09:43
Brave Ye
sudo apt update
sudo apt install certbot python3-certbot-apache -y

nano /etc/apache2/sites-available/default-ssl.conf
# line 2 : change admin email
ServerAdmin webmaster@srv.world
先按住ctrl鍵再按英文o鍵存檔
sudo a2ensite default-ssl
sudo a2enmod ssl
systemctl restart apache2


處理http://自動轉https://
nano /etc/apache2/sites-available/virtual.host.conf

代碼: 選擇全部

<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName zine-tw.com
    ServerAdmin youremail@mail.com
    ErrorLog /var/log/apache2/virtual.host.error.log
    CustomLog /var/log/apache2/virtual.host.access.log combined
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>

sudo a2enmod rewrite
systemctl restart apache2

sudo certbot --apache
驗證systemd timer 自動續期
sudo certbot renew --dry-run