fix(templates): no comments for php + ssl config

This commit is contained in:
mrflos 2022-11-22 10:09:27 +03:00
parent 783952a707
commit 7d944e6fbb
3 changed files with 23 additions and 4 deletions

View file

@ -0,0 +1,9 @@
# ----------------------------------------------------------------------
# | Config file for ssl certificate for <?=$this->e($domain)?> host |
# ----------------------------------------------------------------------
server {
listen [::]:80;
listen 80;
server_name www.<?=$this->e($domain)?> <?=$this->e($domain)?>;
}

View file

@ -1,6 +1,6 @@
[<?=$this->e($user)?>] [<?=$this->e($user)?>]
user = <?=$this->e($user)?> #unix user user = <?=$this->e($user)?>
group = <?=$this->e($user)?> #unix group group = <?=$this->e($user)?>
listen = /var/run/php-fpm-<?=$this->e($user)?>.sock listen = /var/run/php-fpm-<?=$this->e($user)?>.sock
listen.owner = www-data listen.owner = www-data
listen.group = www-data listen.group = www-data
@ -9,4 +9,4 @@ pm.max_children = 75
pm.start_servers = 10 pm.start_servers = 10
pm.min_spare_servers = 5 pm.min_spare_servers = 5
pm.max_spare_servers = 20 pm.max_spare_servers = 20
pm.process_idle_timeout = 10 pm.process_idle_timeout = 10

View file

@ -155,8 +155,19 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
$herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT) $herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT)
); );
} }
$templates = new League\Plates\Engine(dirname(__FILE__).'/templates');
$subDomain = preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0); $subDomain = preg_match('/.'.$_SERVER['maindomain'].'$/isU', $domain, $matches, PREG_OFFSET_CAPTURE, 0);
if (!$subDomain) { if (!$subDomain) {
file_put_contents(
$nginxFile,
$templates->render(
'nginx-for-ssl-certificate',
[
'domain' => $domain,
]
)
);
exec('service nginx force-reload', $output);
exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 --nginx', $output); exec('/root/.acme.sh/acme.sh --issue -d '.$domain.' -d www.'.$domain.' -k ec-384 --nginx', $output);
exec('mkdir -p /etc/letsencrypt/live/'.$domain, $output); exec('mkdir -p /etc/letsencrypt/live/'.$domain, $output);
exec('/root/.acme.sh/acme.sh --install-cert -d '.$domain.' --ecc \ exec('/root/.acme.sh/acme.sh --install-cert -d '.$domain.' --ecc \
@ -166,7 +177,6 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
--ca-file /etc/letsencrypt/live/'.$domain.'/ca.pem \ --ca-file /etc/letsencrypt/live/'.$domain.'/ca.pem \
--reloadcmd "systemctl restart nginx.service"', $output); --reloadcmd "systemctl restart nginx.service"', $output);
} }
$templates = new League\Plates\Engine(dirname(__FILE__).'/templates');
file_put_contents( file_put_contents(
$nginxFile, $nginxFile,
$templates->render( $templates->render(