安裝 apache let's encrypt ssl 憑證

Post Reply
Brave Ye
系統管理員
Posts: 5661
Joined: 2025-11-08, 13:32
Location: Taiwan
Contact:

安裝 apache let's encrypt ssl 憑證

Post by 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

Code: Select all

<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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest