fix(installer): folder and rights problems

This commit is contained in:
mrflos 2023-03-18 09:49:51 +03:00
parent b60f30ad18
commit f8d96156fa
2 changed files with 8 additions and 1 deletions

View file

@ -6,4 +6,8 @@ server {
listen [::]:80; listen [::]:80;
listen 80; listen 80;
server_name www.<?=$this->e($domain)?> <?=$this->e($domain)?>; server_name www.<?=$this->e($domain)?> <?=$this->e($domain)?>;
location ^~ /.well-known/acme-challenge/ {
root /home/<?=$this->e($user)?>/<?=$this->e($domain)?>;
try_files $uri =404;
}
} }

View file

@ -143,6 +143,9 @@ function removeUnixUser($user)
function createNginxConfig($domain, $user, $herseUser, $hersePass) function createNginxConfig($domain, $user, $herseUser, $hersePass)
{ {
// create folder if not exists
exec('sudo -u '.$user.' mkdir -p /home'.'/'.$user.'/'.$domain);
$nginxFile = '/etc/nginx/conf.d/'.$domain.'.conf'; $nginxFile = '/etc/nginx/conf.d/'.$domain.'.conf';
if (empty($herseUser) && empty($hersePass)) { if (empty($herseUser) && empty($hersePass)) {
// no herse needed // no herse needed
@ -150,7 +153,6 @@ function createNginxConfig($domain, $user, $herseUser, $hersePass)
throw new Exception('You need an username AND a password to add a herse.'); throw new Exception('You need an username AND a password to add a herse.');
} else { } else {
// add password file to domain // add password file to domain
exec('sudo -u '.$user.' mkdir -p /home'.'/'.$user.'/'.$domain);
file_put_contents( file_put_contents(
'/home'.'/'.$user.'/'.$domain.'/.htpasswd', '/home'.'/'.$user.'/'.$domain.'/.htpasswd',
$herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT) $herseUser.':'.password_hash($hersePass, PASSWORD_BCRYPT)
@ -224,6 +226,7 @@ function copyYesWikiFiles($domain, $user, $dbUser, $herseUser = null, $hersePass
$destDir = '/home'.'/'.$user.'/'.$domain; $destDir = '/home'.'/'.$user.'/'.$domain;
$sudo = 'sudo -u '.$user.' '; $sudo = 'sudo -u '.$user.' ';
exec($sudo.' mkdir -p '.$destDir, $output); exec($sudo.' mkdir -p '.$destDir, $output);
exec($sudo.' chown '.$user.':'.$user.' -R '.$destDir, $output);
if (file_exists($tmpFile)) { if (file_exists($tmpFile)) {
unlink($tmpFile); unlink($tmpFile);
} }