ubuntu系統制作免費https教程

更新系統軟件

$ sudo apt-get update

安裝certbot

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get install python-certbot-nginx

生成相關文件

sudo certbot certonly --webroot -w /var/www/HelloPhp/public -d shop.xxx.com

啟用443端口

server {
        # listen 80;
        
    #443_start(添加443配置)
        listen 443 ssl;
        listen [::]:443 ssl ipv6only=on;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/shop.xxx.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/shop.xxx.com/privkey.pem;
        # ssl_trusted_certificate /etc/letsencrypt/live/your.domain.com/chain.aem;
    #443_end

        #以下為正常配置
        root /var/www/HelloPhp/public;
        index index.php index.html index.htm;
        server_name shop.xxx.com 112.74.xxx.43;

        location / {
            try_files $uri  /index.php;
        }
         location ~ \.php$ {
                #fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                # With php5-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

域名默認不添加https也可訪問

server {
    listen 80;
    # listen [::]:80 default_server;
    server_name shop.xxx.com;
    return 301 https://$server_name$request_uri;
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容