https安装到配置

centos7

nginx的安装

yum install nginx

nginx 重新启动

service nginx restart

安装成功之后 

nginx的配置文件

/etc/nginx/nginx.conf

进行配置之前先从控制台上面将你申请好的ssl证书下载了(不会的请看云的教程 这里展示的是腾讯云nginx的https配置)

将下载好的证书放到目录etc/nginx/crt 目录下面

首先在 ect/nginx/ 下面创建一个crt目录 然后将你的证书放到这个文件夹中

mkdir crt

server {
        listen 443;
        server_name www.xxxx.com;
        root   /home/swoole;
        ssl on;
        ssl_certificate /etc/nginx/crt/1_www.htown.xyz_bundle.crt;
        ssl_certificate_key /etc/nginx/crt/2_www.htown.xyz.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        include /etc/nginx/default.d/*.conf;
        location / {

            index  index.html index.htm index.php;
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
        }
         location ~ .*.php?$ {
                           # 设置监听端口
                           fastcgi_pass   127.0.0.1:9000;
                           # 设置nginx的默认首页文件(上面已经设置过了,可以删除)
                           fastcgi_index  index.php;
                           #fastcgi_split_path_info ^(.+\.php)(.*)$;     #增加这一句
                           fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
                           fastcgi_param PATH_INFO $fastcgi_path_info;    #增加这一句
                           # 设置脚本文件请求的路径
                           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                           #fastcgi_param  SCRIPT_FILENAME  /home$fastcgi_script_name;
                           # 引入fastcgi的配置文件
                           include        fastcgi_params;
                       }
    }

配置完成后 请执行下面命令

nginx -t  查看有没有报错如果没有报错请重新启动

service nginx restart  

如果看到这个错误请检查你的配置文件 也可以通过nginx -t 来看一下报的错误 

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

如果都没有问题那恭喜您配置已经成功

通过https+域名访问的网站

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值