php ssl tls_如何给网站配置 免费的SSL/TLS证书?

如今跟支付和推广相关的业务需求都需要网站支持 https.很多付费的ssl证书可以买。那么有免费的配置方式吗?当然

0226180d5dffa0123d4fc8dda173666e.png

上面是官网截图。看不习惯英文的右上角有 语言选项,支持中文。

步骤一

登录注册地址:注册登录

不需要验证手机号,只需要验证邮箱。比较适合那些不喜欢手机号的,比如我,哈哈。

步骤二

填入需要申请证书的域名

5d2d5764ee18edf8057df37cbac5ae06.png

c65386a5890b8a98cb52add779211034.png

步骤三

验证域名的归属,证明域名是你的。两种方式

http: 根据http请求访问,返回指定的token串

dns: 通过添加dns前缀验证

下载证书部署

1b9ab83c1c889220af83f9a0f3c1067c.png

下载后是一个zip压缩包,里面会包含证书文件,加压后文件如下

4c33e7e1233e750f3c2734f7d6027976.png

nginx 配置方式

我部署Larvel项目时 nginx 配置

user nginx;

worker_processes auto;

error_log /var/log/nginx/error.log;

pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.

include /usr/share/nginx/modules/*.conf;

events {

worker_connections 1024;

}

http {

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 2048;

include /etc/nginx/mime.types;

default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.

# See http://nginx.org/en/docs/ngx_core_module.html#include

# for more information.

include /etc/nginx/conf.d/*.conf;

ssl_certificate "/path/to/fullchain.crt";

ssl_certificate_key "/path/to/private/private.pem";

server {

listen 80;

listen 443 ssl http2;

server_name yourdomain.com;

root /home/yourdomain.com/public;

ssl_certificate "/etc/pki/nginx/fullchain.crt";

ssl_certificate_key "/etc/pki/nginx/private/private.pem";

ssl_protocols TLSv1.1 TLSv1.2;

ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

ssl_prefer_server_ciphers on;

ssl_session_cache shared:SSL:10m;

ssl_session_timeout 10m;

add_header X-Frame-Options "SAMEORIGIN";

add_header X-XSS-Protection "1; mode=block";

add_header X-Content-Type-Options "nosniff";

index index.html index.htm index.php;

charset utf-8;

location / {

try_files $uri $uri/ /index.php?$query_string;

}

location = /favicon.ico { access_log off; log_not_found off; }

location = /robots.txt { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~ \.php$ {

# fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

include fastcgi_params;

}

location ~ /\.(?!well-known).* {

deny all;

}

}

复制代码

nginx 重启

https 就可以访问了。中间有些过程省略了,不懂的留言问我。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值