ACME成功后执行/www/w.sh 就是Le_ReloadCmd为sh /www/w.sh a.com就是acme的申请域名,基本思路就是将acme申请下来的证书文件覆盖到相应位置 ,下面两个例子是覆盖宝塔面板的ssl w.sh内容: \cp -rf /www/server/panel/vhost/cert/a.com/fullchain.pem /www/server/panel/ssl/certificate.pem \cp -rf /www/server/panel/vhost/cert/a.com/privkey.pem /www/server/panel/ssl/privateKey.pem bt restart nginx -s reload /www/server/php/74/bin/php /www/wwwroot/zidong.com/public/index.php //用的TP6 要composer安装tencentcloud/tencentcloud-sdk-php和alibabacloud/dcdn-20180115 $accessKeyId, // 必填,您的 AccessKey Secret "accessKeySecret" => $accessKeySecret ]); // Endpoint 请参考 https://api.aliyun.com/product/dcdn $config->endpoint = "dcdn.aliyuncs.com"; return new Dcdn($config); } private function main($domain,$p,$k){ //阿里云的全站加速 if(empty($domain)) return false; $client = self::createClient('', ''); $setDcdnDomainSSLCertificateRequest = new SetDcdnDomainSSLCertificateRequest([ "domainName" => $domain, "certName" => 'PHPAUTO'.date('YmdHis'), "certType" => "upload", "SSLProtocol" => "on", "SSLPub" => $p, "SSLPri" => $k ]); $runtime = new RuntimeOptions([]); try { // 复制代码运行请自行打印 API 的返回值 $client->setDcdnDomainSSLCertificateWithOptions($setDcdnDomainSSLCertificateRequest, $runtime); echo $domain." success \n"; } catch (\Exception $error) { if (!($error instanceof TeaError)) { $error = new TeaError([], $error->getMessage(), $error->getCode(), $error); } // 错误 message var_dump($error->message); // 诊断地址 var_dump($error->data["Recommend"]); Utils::assertAsString($error->message); } } //acme续期之后自动执行这个 public function index() { if(request()->ip()!='0.0.0.0'){ echo request()->ip().' Error'; exit; } //证书位置 自己更改 $zhengshu_key=__DIR__.'/../../privkey.pem'; $zhengshu_crt=__DIR__.'/../../fullchain.pem'; //阿里云上面的全站加速cdn域名 例子: $aliyun_domain=[ 'a.com', 'erp.b.com' ]; foreach ($aliyun_domain as $v){ $this->main($v,file_get_contents($zhengshu_crt),file_get_contents($zhengshu_key)); sleep(2); } //腾讯云秘钥 $SecretId=''; $SecretKey=''; //腾讯云cdn域名 $add_domain=[ 'a.com', 'erp.b.com' ]; try { // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密 // 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305 // 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取 $cred = new Credential($SecretId, $SecretKey); // 实例化一个http选项,可选的,没有特殊需求可以跳过 $httpProfile = new HttpProfile(); $httpProfile->setEndpoint("ssl.tencentcloudapi.com"); // 实例化一个client选项,可选的,没有特殊需求可以跳过 $clientProfile = new ClientProfile(); $clientProfile->setHttpProfile($httpProfile); // 实例化要请求产品的client对象,clientProfile是可选的 $client = new SslClient($cred, "", $clientProfile); // 实例化一个请求对象,每个接口都会对应一个request对象 $req = new UploadCertificateRequest(); $params = array( "CertificatePublicKey" => file_get_contents($zhengshu_crt), "CertificatePrivateKey" => file_get_contents($zhengshu_key), "Alias" => 'PHPAUTO'.date('YmdHis'), "CertificateUse" => "CDN" ); $req->fromJsonString(json_encode($params)); // 返回的resp是一个UploadCertificateResponse的实例,与请求对象对应 $resp = $client->UploadCertificate($req); // 输出json格式的字符串回包 $resp_json=json_decode($resp->toJsonString(),true); if(!isset($resp_json['CertificateId'])){ throw new Exception("上传证书错误,没有获取到证书id"); } $httpProfilecdn = new HttpProfile(); $httpProfilecdn->setEndpoint("cdn.tencentcloudapi.com"); $clientProfilecdn = new ClientProfile(); $clientProfilecdn->setHttpProfile($httpProfilecdn); $clientcdn = new CdnClient($cred, "", $clientProfilecdn); // ---------------------------- // 实例化一个请求对象,每个接口都会对应一个request对象 $reqcdn = new UpdateDomainConfigRequest(); foreach ($add_domain as $v){ $paramscdn = array( "Domain" => $v, "Https" => array( "Switch" => "on", "CertInfo" => array( "CertId" => $resp_json['CertificateId'] ) ) ); $reqcdn->fromJsonString(json_encode($paramscdn)); // 返回的resp是一个UpdateDomainConfigResponse的实例,与请求对象对应 $respcdn = $clientcdn->UpdateDomainConfig($reqcdn); echo $respcdn->toJsonString().'\n'; sleep(1); } } catch(TencentCloudSDKException $e) { echo $e; } } }