Update ApacheWebsiteCreate.php

This commit is contained in:
Bozhidar Slaveykov 2024-04-04 14:44:49 +03:00
parent 30e71d0131
commit c14e6e76fa

View file

@ -53,11 +53,6 @@ class ApacheWebsiteCreate
$domainRoot = '/home/'.$this->user.'/domains/'.$this->domain;
$homeRoot = '/home/'.$this->user;
//copy php suexe to {'home'}/fcgi-bin
// $fileManagerApi = new FileManagerApi();
$settings = [
'port' => 80,
'domain' => $this->domain,
@ -70,14 +65,13 @@ class ApacheWebsiteCreate
];
$apache2Sample = view('actions.samples.ubuntu.apache2-conf', $settings)->render();
$fileManagerApi = new FileManagerApi();
$fileManagerApi->mkdir($settings['domainRoot']);
$fileManagerApi->mkdir($settings['domainPublic']);
mkdir($settings['domainRoot']);
mkdir($settings['domainPublic']);
ShellApi::exec('chmod -R 775 /etc/apache2/sites-available/');
$fileManagerApi->filePutContents('/etc/apache2/sites-available/' . $settings['domain'] . '.conf', $apache2Sample);
file_put_contents('/etc/apache2/sites-available/' . $settings['domain'] . '.conf', $apache2Sample);
$indexContent = '
@ -89,24 +83,23 @@ class ApacheWebsiteCreate
';
$fileManagerApi->filePutContents($settings['domainPublic'] . '/index.php', $indexContent);
file_put_contents($settings['domainPublic'] . '/index.php', $indexContent);
ShellApi::exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $allDomainsRoot);
ShellApi::exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $homeRoot);
shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $allDomainsRoot);
shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $homeRoot);
ShellApi::exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainRoot']);
ShellApi::exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainPublic']);
shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainRoot']);
shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainPublic']);
ShellApi::exec('chmod -R 775 ' . $allDomainsRoot);
ShellApi::exec('chmod -R 775 ' . $homeRoot);
ShellApi::exec('chmod -R 775 ' . $settings['domainRoot']);
ShellApi::exec('chmod -R 775 ' . $settings['domainPublic']);
ShellApi::exec('a2ensite ' . $settings['domain'] . '.conf');
ShellApi::exec('systemctl reload apache2');
shell_exec('chmod -R 775 ' . $allDomainsRoot);
shell_exec('chmod -R 775 ' . $homeRoot);
shell_exec('chmod -R 775 ' . $settings['domainRoot']);
shell_exec('chmod -R 775 ' . $settings['domainPublic']);
shell_exec('a2ensite ' . $settings['domain'] . '.conf');
shell_exec('systemctl reload apache2');
return [
'domain' => $this->domain,
'domainPublic' => $settings['domainPublic'],