介绍
基本信息
作者:朱明宇
名称:将本地的 SSL 证书恢复到本地的 LNMP + SSL
作用:将本地的 SSL 证书恢复到本地的 LNMP + SSL
使用方法
1. 将网站的 SSL 公钥、网站的 SSL 私钥 2 个文件放在此脚本中变量 tmppath 对应的目录里
2. 给此脚本添加执行权限
3. 执行此脚本
脚本分割线里的变量
tmppath=/bcache #本地存放 SSL 证书的名称
cmidname=fullchain #SSL 公钥的名称
kmidname=privkey #SSL 私钥的名称
sslpath=/etc/letsencrypt/live/eternalcenter.com/ #本地 LNMP + SSL 存放公私的目录
注意
1. 本地需要已经搭建好 LNMP 平台
2. 必须以 root 的身份执行此脚本
脚本
#!/bin/bash
####################### Separator ########################
tmppath=/bcache
cmidname=fullchain
kmidname=privkey
sslpath=/etc/letsencrypt/live/eternalcenter.com/
####################### Separator ########################
nowdirectory=`pwd`
cd $tmppath
crtfile=`ls | grep $cmidname | grep -E \.pem$ | tail -1`
keyfile=`ls | grep $kmidname | grep -E \.pem$ | tail -1`
echo $crtfile
if [ -n "$crtfile" ];then
rm -rf $sslpath/$crtfile
mkdir -p $sslpath &> /dev/null
mv $crtfile $sslpath/
chcon -t httpd_config_t $sslpath/*
fi
echo $keyfile
if [ -n "$keyfile" ];then
rm -rf $sslpath/$keyfile
mkdir -p $sslpath &> /dev/null
mv $keyfile $sslpath/
chcon -t httpd_config_t $sslpath/*
fi
chcon -t httpd_config_t $sslpath
sudo systemctl restart nginx
sudo systemctl restart php-fpm
cd $nowdirectory
