|
@@ -2,18 +2,20 @@
|
|
|
|
|
|
namespace App\Actions;
|
|
|
|
|
|
-use App\FileManagerApi;
|
|
|
-use App\ShellApi;
|
|
|
-use App\VirtualHosts\ApacheVirtualHostManager;
|
|
|
-
|
|
|
class ApacheWebsiteCreate
|
|
|
{
|
|
|
public $domain;
|
|
|
+
|
|
|
public $user;
|
|
|
+
|
|
|
public $email;
|
|
|
+
|
|
|
public $password;
|
|
|
+
|
|
|
public $isMainDomain = false;
|
|
|
+
|
|
|
public $additionalServices = [];
|
|
|
+
|
|
|
public $features = [];
|
|
|
|
|
|
public function setDomain($domain)
|
|
@@ -62,15 +64,15 @@ class ApacheWebsiteCreate
|
|
|
}
|
|
|
|
|
|
if ($this->isMainDomain) {
|
|
|
- $allDomainsRoot = '/home/' . $this->user . '/public_html';
|
|
|
- $domainRoot = '/home/' . $this->user;
|
|
|
- $domainPublic = '/home/' . $this->user . '/public_html';
|
|
|
- $homeRoot = '/home/' . $this->user;
|
|
|
+ $allDomainsRoot = '/home/'.$this->user.'/public_html';
|
|
|
+ $domainRoot = '/home/'.$this->user;
|
|
|
+ $domainPublic = '/home/'.$this->user.'/public_html';
|
|
|
+ $homeRoot = '/home/'.$this->user;
|
|
|
} else {
|
|
|
- $allDomainsRoot = '/home/' . $this->user . '/domains';
|
|
|
- $domainRoot = '/home/' . $this->user . '/domains/' . $this->domain;
|
|
|
- $domainPublic = $domainRoot . '/public_html';
|
|
|
- $homeRoot = '/home/' . $this->user;
|
|
|
+ $allDomainsRoot = '/home/'.$this->user.'/domains';
|
|
|
+ $domainRoot = '/home/'.$this->user.'/domains/'.$this->domain;
|
|
|
+ $domainPublic = $domainRoot.'/public_html';
|
|
|
+ $homeRoot = '/home/'.$this->user;
|
|
|
}
|
|
|
|
|
|
$apacheVirtualHostConfigs = app()->virtualHostManager->getConfigs($this->additionalServices);
|
|
@@ -89,23 +91,22 @@ class ApacheWebsiteCreate
|
|
|
$settings = array_merge($settings, $apacheVirtualHostConfigs);
|
|
|
$apache2Sample = view('actions.samples.ubuntu.apache2-conf', $settings)->render();
|
|
|
|
|
|
- if (!is_dir($homeRoot)) {
|
|
|
+ if (! is_dir($homeRoot)) {
|
|
|
mkdir($homeRoot);
|
|
|
}
|
|
|
- if (!is_dir($allDomainsRoot)) {
|
|
|
+ if (! is_dir($allDomainsRoot)) {
|
|
|
mkdir($allDomainsRoot);
|
|
|
}
|
|
|
- if (!is_dir($domainRoot)) {
|
|
|
+ if (! is_dir($domainRoot)) {
|
|
|
mkdir($domainRoot);
|
|
|
}
|
|
|
- if (!is_dir($domainPublic)) {
|
|
|
+ if (! is_dir($domainPublic)) {
|
|
|
mkdir($domainPublic);
|
|
|
}
|
|
|
|
|
|
shell_exec('chmod -R 775 /etc/apache2/sites-available/');
|
|
|
|
|
|
- file_put_contents('/etc/apache2/sites-available/' . $settings['domain'] . '.conf', $apache2Sample);
|
|
|
-
|
|
|
+ file_put_contents('/etc/apache2/sites-available/'.$settings['domain'].'.conf', $apache2Sample);
|
|
|
|
|
|
$indexContent = '
|
|
|
|
|
@@ -115,22 +116,21 @@ class ApacheWebsiteCreate
|
|
|
|
|
|
';
|
|
|
|
|
|
+ file_put_contents($settings['domainPublic'].'/index.php', $indexContent);
|
|
|
|
|
|
- file_put_contents($settings['domainPublic'] . '/index.php', $indexContent);
|
|
|
-
|
|
|
- shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $allDomainsRoot);
|
|
|
- shell_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);
|
|
|
|
|
|
- shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainRoot']);
|
|
|
- shell_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']);
|
|
|
|
|
|
- shell_exec('chmod -R 775 ' . $allDomainsRoot);
|
|
|
- shell_exec('chmod -R 775 ' . $homeRoot);
|
|
|
+ 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('chmod -R 775 '.$settings['domainRoot']);
|
|
|
+ shell_exec('chmod -R 775 '.$settings['domainPublic']);
|
|
|
|
|
|
- shell_exec('a2ensite ' . $settings['domain'] . '.conf');
|
|
|
+ shell_exec('a2ensite '.$settings['domain'].'.conf');
|
|
|
shell_exec('systemctl reload apache2');
|
|
|
|
|
|
return [
|
|
@@ -141,7 +141,7 @@ class ApacheWebsiteCreate
|
|
|
'user' => $this->user,
|
|
|
'email' => $this->email,
|
|
|
'linuxUser' => $linuxUser,
|
|
|
- 'apache2Sample' => $apache2Sample
|
|
|
+ 'apache2Sample' => $apache2Sample,
|
|
|
];
|
|
|
|
|
|
}
|