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;

}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值