|
@@ -0,0 +1,61 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Actions;
|
|
|
+
|
|
|
+use App\FileManagerApi;
|
|
|
+use App\ShellApi;
|
|
|
+
|
|
|
+class ApacheWebsiteApplySSLVirtualHost
|
|
|
+{
|
|
|
+ public $domain;
|
|
|
+ public $domainRoot;
|
|
|
+ public $sslCertificateFilePath;
|
|
|
+ public $sslCertificateKeyFilePath;
|
|
|
+ public $sslCertificateChainFilePath;
|
|
|
+
|
|
|
+ public function setSslCertificateFilePath($sslCertificateFilePath)
|
|
|
+ {
|
|
|
+ $this->sslCertificateFilePath = $sslCertificateFilePath;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setSslCertificateKeyFilePath($sslCertificateKeyFilePath)
|
|
|
+ {
|
|
|
+ $this->sslCertificateKeyFilePath = $sslCertificateKeyFilePath;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setSslCertificateChainFilePath($sslCertificateChainFilePath)
|
|
|
+ {
|
|
|
+ $this->sslCertificateChainFilePath = $sslCertificateChainFilePath;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDomain($domain)
|
|
|
+ {
|
|
|
+ $this->domain = $domain;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDomainRoot($domainRoot)
|
|
|
+ {
|
|
|
+ $this->domainRoot = $domainRoot;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ $settings = [
|
|
|
+ 'port'=> 443,
|
|
|
+ 'domain' => $this->domain,
|
|
|
+ 'domainRoot' => '/var/www/'.$this->domain,
|
|
|
+ 'group' => 'www-data',
|
|
|
+ 'sslCertificateFilePath' => $this->sslCertificateFilePath,
|
|
|
+ 'sslCertificateKeyFilePath' => $this->sslCertificateKeyFilePath,
|
|
|
+ 'sslCertificateChainFilePath' => $this->sslCertificateChainFilePath,
|
|
|
+ ];
|
|
|
+ $apache2SSLSample = view('actions.samples.ubuntu.apache2-ssl-conf',$settings)->render();
|
|
|
+
|
|
|
+ $fileManagerApi = new FileManagerApi();
|
|
|
+ $fileManagerApi->filePutContents('/etc/apache2/sites-available/'.$this->domain.'-ssl.conf', $apache2SSLSample);
|
|
|
+ $fileManagerApi->symlink('/etc/apache2/sites-available/'.$this->domain.'-ssl.conf', '/etc/apache2/sites-enabled/'.$this->domain.'-ssl.conf');
|
|
|
+
|
|
|
+ ShellApi::exec('service apache2 restart');
|
|
|
+
|
|
|
+ }
|
|
|
+}
|