作者 刘锟

update

@@ -57,7 +57,7 @@ public function checkDomainSsl() @@ -57,7 +57,7 @@ public function checkDomainSsl()
57 $site_domain_list = $this->bt->WebDoaminList($site_id); 57 $site_domain_list = $this->bt->WebDoaminList($site_id);
58 $apply_ssl_domain_list = []; 58 $apply_ssl_domain_list = [];
59 foreach ($site_domain_list as $val) { 59 foreach ($site_domain_list as $val) {
60 - if (strpos($val['name'], '*') === false && $this->check_domain_record($val['name'], ['domain'=>'','ip' => $site_ip])) { 60 + if (strpos($val['name'], '*') === false && $this->check_domain_record($val['name'], ['domain' => '', 'ip' => $site_ip])) {
61 $apply_ssl_domain_list[] = $val['name']; 61 $apply_ssl_domain_list[] = $val['name'];
62 } 62 }
63 } 63 }
@@ -96,9 +96,23 @@ public function checkDomainSsl() @@ -96,9 +96,23 @@ public function checkDomainSsl()
96 $amp_site_id = $amp_site_list['data'][0]['id']; 96 $amp_site_id = $amp_site_list['data'][0]['id'];
97 $amp_host = $amp_site_list['data'][0]['name']; 97 $amp_host = $amp_site_list['data'][0]['name'];
98 98
  99 + //申请证书之前,还原主站配置
  100 + $amp_config_before = file_get_contents(public_path('amp_site_default.txt'));
  101 + $re_amp_config_before = $this->bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $amp_host . '.conf', $amp_config_before, 'utf-8', 1);
  102 + if (!($re_amp_config_before['status'] ?? false)) {
  103 + throw new \Exception($re_amp_config_before['msg'] ?? '还原AMP站nginx配置失败');
  104 + }
  105 +
99 //设置站点证书 106 //设置站点证书
100 $this->setDomainSsl($amp_site_id, $amp_host, [$amp_host]); 107 $this->setDomainSsl($amp_site_id, $amp_host, [$amp_host]);
101 108
  109 + //申请证书之后,更新主站配置
  110 + $amp_config_after = file_get_contents(public_path('amp_site_config.txt'));
  111 + $re_amp_config_after = $this->bt->SaveFileBody('/www/server/panel/vhost/nginx/' . $amp_host . '.conf', $amp_config_after, 'utf-8', 1);
  112 + if (!($re_amp_config_after['status'] ?? false)) {
  113 + throw new \Exception($re_amp_config_after['msg'] ?? '更新AMP站nginx配置失败');
  114 + }
  115 +
102 $this->output('AMP站证书更新成功'); 116 $this->output('AMP站证书更新成功');
103 } 117 }
104 } 118 }