mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
update
This commit is contained in:
parent
317113f4cd
commit
dc7037cd5b
4 changed files with 55 additions and 26 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App;
|
||||
|
||||
use App\Models\DomainSslCertificate;
|
||||
use App\VirtualHosts\DTO\ApacheVirtualHostSettings;
|
||||
|
||||
class MasterDomain
|
||||
{
|
||||
|
@ -39,15 +40,15 @@ class MasterDomain
|
|||
return false;
|
||||
}
|
||||
|
||||
$apacheVirtualHostBuilder = new \App\VirtualHosts\ApacheVirtualHostBuilder();
|
||||
$apacheVirtualHostBuilder->setDomain($this->domain);
|
||||
$apacheVirtualHostBuilder->setDomainPublic($this->domainPublic);
|
||||
$apacheVirtualHostBuilder->setDomainRoot($this->domainRoot);
|
||||
$apacheVirtualHostBuilder->setHomeRoot($this->domainRoot);
|
||||
$apacheVirtualHostBuilder->setServerAdmin($this->email);
|
||||
$apacheVirtualHostBuilder->setDomainAlias('*.'.$this->domain);
|
||||
$apacheVirtualHost = new ApacheVirtualHostSettings();
|
||||
$apacheVirtualHost->setDomain($this->domain);
|
||||
$apacheVirtualHost->setDomainPublic($this->domainPublic);
|
||||
$apacheVirtualHost->setDomainRoot($this->domainRoot);
|
||||
$apacheVirtualHost->setHomeRoot($this->domainRoot);
|
||||
$apacheVirtualHost->setServerAdmin($this->email);
|
||||
$apacheVirtualHost->setDomainAlias('*.'.$this->domain);
|
||||
|
||||
$apacheBaseConfig = $apacheVirtualHostBuilder->buildConfig();
|
||||
$virtualHostSettings = $apacheVirtualHost->getSettings();
|
||||
|
||||
if ($fixPermissions) {
|
||||
shell_exec('mkdir -p /var/www/logs/apache2');
|
||||
|
@ -85,7 +86,7 @@ class MasterDomain
|
|||
}
|
||||
}
|
||||
|
||||
$apacheBaseConfigWithSSL = null;
|
||||
$virtualHostSettingsWithSSL = null;
|
||||
|
||||
if ($findDomainSSLCertificate) {
|
||||
|
||||
|
@ -115,34 +116,33 @@ class MasterDomain
|
|||
file_put_contents($sslCertificateChainFile, $findDomainSSLCertificate->certificate_chain);
|
||||
}
|
||||
|
||||
$apacheVirtualHostBuilder->setPort(443);
|
||||
$apacheVirtualHostBuilder->setSSLCertificateFile($sslCertificateFile);
|
||||
$apacheVirtualHostBuilder->setSSLCertificateKeyFile($sslCertificateKeyFile);
|
||||
$apacheVirtualHostBuilder->setSSLCertificateChainFile($sslCertificateChainFile);
|
||||
|
||||
$apacheBaseConfigWithSSL = $apacheVirtualHostBuilder->buildConfig();
|
||||
$apacheVirtualHost->setPort(443);
|
||||
$apacheVirtualHost->setSSLCertificateFile($sslCertificateFile);
|
||||
$apacheVirtualHost->setSSLCertificateKeyFile($sslCertificateKeyFile);
|
||||
$apacheVirtualHost->setSSLCertificateChainFile($sslCertificateChainFile);
|
||||
|
||||
$virtualHostSettingsWithSSL = $apacheVirtualHost->getSettings();
|
||||
|
||||
}
|
||||
// End install SSL
|
||||
|
||||
if ($fixPermissions) {
|
||||
$domainIndexFile = $this->domainPublic . '/index.html';
|
||||
if (file_exists($domainIndexFile)) {
|
||||
$domainIndexFileContent = file_get_contents($domainIndexFile);
|
||||
if (str_contains($domainIndexFileContent, 'Apache2 Debian Default Page')) {
|
||||
$indexContent = file_get_contents(base_path('resources/views/actions/samples/apache/html/app-index.html'));
|
||||
file_put_contents($this->domainPublic . '/index.html', $indexContent);
|
||||
$domainIndexFile = $this->domainPublic . '/index.html';
|
||||
if (file_exists($domainIndexFile)) {
|
||||
$domainIndexFileContent = file_get_contents($domainIndexFile);
|
||||
if (str_contains($domainIndexFileContent, 'Apache2 Debian Default Page')) {
|
||||
$indexContent = file_get_contents(base_path('resources/views/actions/samples/apache/html/app-index.html'));
|
||||
file_put_contents($this->domainPublic . '/index.html', $indexContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shell_exec('chown -R www-data:www-data ' . $this->domainPublic);
|
||||
shell_exec('chmod -R 755 ' . $this->domainPublic);
|
||||
shell_exec('chown -R www-data:www-data ' . $this->domainPublic);
|
||||
shell_exec('chmod -R 755 ' . $this->domainPublic);
|
||||
}
|
||||
|
||||
return [
|
||||
'apacheBaseConfig' => $apacheBaseConfig,
|
||||
'apacheBaseConfigWithSSL' => $apacheBaseConfigWithSSL ?? null
|
||||
'virtualHostSettings' => $virtualHostSettings,
|
||||
'virtualHostSettingsWithSSL' => $virtualHostSettingsWithSSL ?? null
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,35 @@ class ApacheBuild
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Make master domain virtual host
|
||||
if (!empty(setting('general.master_domain'))) {
|
||||
// Make master domain virtual host
|
||||
$masterDomain = new MasterDomain();
|
||||
$domainVirtualHost = $masterDomain->configureVirtualHost();
|
||||
if (isset($domainVirtualHost['virtualHostSettings'])) {
|
||||
$virtualHosts[] = $domainVirtualHost['virtualHostSettings'];
|
||||
}
|
||||
if (isset($domainVirtualHost['virtualHostSettingsWithSSL'])) {
|
||||
$virtualHosts[] = $domainVirtualHost['virtualHostSettingsWithSSL'];
|
||||
}
|
||||
}
|
||||
|
||||
// Make wildcard domain virtual host
|
||||
$wildcardDomain = setting('general.wildcard_domain');
|
||||
if (!empty($wildcardDomain)) {
|
||||
// Make wildcard domain virtual host
|
||||
$masterDomain = new MasterDomain();
|
||||
$masterDomain->domain = $wildcardDomain;
|
||||
$domainVirtualHost = $masterDomain->configureVirtualHost();
|
||||
if (isset($domainVirtualHost['virtualHostSettings'])) {
|
||||
$virtualHosts[] = $domainVirtualHost['virtualHostSettings'];
|
||||
}
|
||||
if (isset($domainVirtualHost['virtualHostSettingsWithSSL'])) {
|
||||
$virtualHosts[] = $domainVirtualHost['virtualHostSettingsWithSSL'];
|
||||
}
|
||||
}
|
||||
|
||||
$apache2 = view('actions.samples.ubuntu.apache2-conf-build', [
|
||||
'virtualHosts' => $virtualHosts
|
||||
])->render();
|
||||
|
|
Loading…
Reference in a new issue