Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the simply-static domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/wp-includes/functions.php on line 6121
2025 年 1 月

给网站添加https

Let’s Encrypt 是一个开源的证书颁发机构

sudo apt-get update
sudo apt-get install certbot
sudo systemctl stop apache2

sudo certbot certonly --standalone -d www.mixdiy.com

sudo a2enmod ssl
sudo systemctl restart apache2

sudo nano /etc/apache2/sites-available/samplepi.com-ssl.conf

<VirtualHost *:443>
    ServerName www.mixdiy.com
    DocumentRoot /var/www/html
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/samplepi.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/samplepi.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/samplepi.com/chain.pem

    # 其他可能的配置项,比如日志配置等
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # 重定向 HTTP 到 HTTPS
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =www.mixdiycat.com
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
    </IfModule>
</VirtualHost>

sudo a2ensite samplepi.com-ssl.conf
sudo systemctl reload apache2

sudo nano /etc/apache2/sites-available/samplepi.com.conf

<VirtualHost *:80>
    ServerName samplepi.com
    Redirect permanent / https://samplepi.com/
</VirtualHost>

sudo a2ensite samplepi.com.conf
sudo systemctl reload apache2