mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 17:10:29 +00:00
130 lines
3.7 KiB
Text
130 lines
3.7 KiB
Text
|
<?php
|
||
|
|
||
|
namespace app\VirtualHosts;
|
||
|
|
||
|
use App\MasterDomain;
|
||
|
use App\Models\Domain;
|
||
|
|
||
|
class ApacheBuildOriginal
|
||
|
{
|
||
|
|
||
|
public $fixPermissions = false;
|
||
|
|
||
|
public function fixPermissions()
|
||
|
{
|
||
|
$this->fixPermissions = true;
|
||
|
}
|
||
|
|
||
|
public function build()
|
||
|
{
|
||
|
$virtualHostMerged = '
|
||
|
#=========================================================================#
|
||
|
# PHYRE HOSTING PANEL - Default Web Domain Template #
|
||
|
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
|
||
|
# https://phyrepanel.com/docs/server-administration/web-templates.html #
|
||
|
#=========================================================================#
|
||
|
|
||
|
DefaultRuntimeDir ${APACHE_RUN_DIR}
|
||
|
PidFile ${APACHE_PID_FILE}
|
||
|
Timeout 300
|
||
|
KeepAlive On
|
||
|
MaxKeepAliveRequests 100
|
||
|
KeepAliveTimeout 5
|
||
|
|
||
|
User ${APACHE_RUN_USER}
|
||
|
Group ${APACHE_RUN_GROUP}
|
||
|
|
||
|
HostnameLookups Off
|
||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||
|
LogLevel warn
|
||
|
|
||
|
IncludeOptional mods-enabled/*.load
|
||
|
IncludeOptional mods-enabled/*.conf
|
||
|
|
||
|
Listen 80
|
||
|
|
||
|
<IfModule ssl_module>
|
||
|
Listen 443
|
||
|
</IfModule>
|
||
|
|
||
|
<IfModule mod_gnutls.c>
|
||
|
Listen 443
|
||
|
</IfModule>
|
||
|
|
||
|
<Directory />
|
||
|
Options FollowSymLinks
|
||
|
AllowOverride None
|
||
|
Require all denied
|
||
|
</Directory>
|
||
|
|
||
|
<Directory /usr/share>
|
||
|
AllowOverride None
|
||
|
Require all granted
|
||
|
</Directory>
|
||
|
|
||
|
<Directory /var/www/>
|
||
|
Options Indexes FollowSymLinks
|
||
|
AllowOverride None
|
||
|
Require all granted
|
||
|
</Directory>
|
||
|
|
||
|
AccessFileName .htaccess
|
||
|
|
||
|
<FilesMatch "^\.ht">
|
||
|
Require all denied
|
||
|
</FilesMatch>
|
||
|
|
||
|
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
||
|
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||
|
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
||
|
LogFormat "%{Referer}i -> %U" referer
|
||
|
LogFormat "%{User-agent}i" agent
|
||
|
|
||
|
IncludeOptional conf-enabled/*.conf
|
||
|
|
||
|
';
|
||
|
$getAllDomains = Domain::all();
|
||
|
foreach ($getAllDomains as $domain) {
|
||
|
|
||
|
$domainVirtualHost = $domain->configureVirtualHost($this->fixPermissions);
|
||
|
if (isset($domainVirtualHost['apacheBaseConfig'])) {
|
||
|
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfig'] . "\n\n";
|
||
|
}
|
||
|
if (isset($domainVirtualHost['apacheBaseConfigWithSSL'])) {
|
||
|
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfigWithSSL'] . "\n\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!empty(setting('general.master_domain'))) {
|
||
|
// Make master domain virtual host
|
||
|
$masterDomain = new MasterDomain();
|
||
|
$domainVirtualHost = $masterDomain->configureVirtualHost($this->fixPermissions);
|
||
|
if (isset($domainVirtualHost['apacheBaseConfig'])) {
|
||
|
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfig'] . "\n\n";
|
||
|
}
|
||
|
if (isset($domainVirtualHost['apacheBaseConfigWithSSL'])) {
|
||
|
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfigWithSSL'] . "\n\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$wildcardDomain = setting('general.wildcard_domain');
|
||
|
if (!empty($wildcardDomain)) {
|
||
|
// Make wildcard domain virtual host
|
||
|
$masterDomain = new MasterDomain();
|
||
|
$masterDomain->domain = $wildcardDomain;
|
||
|
$domainVirtualHost = $masterDomain->configureVirtualHost($this->fixPermissions);
|
||
|
if (isset($domainVirtualHost['apacheBaseConfig'])) {
|
||
|
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfig'] . "\n\n";
|
||
|
}
|
||
|
if (isset($domainVirtualHost['apacheBaseConfigWithSSL'])) {
|
||
|
$virtualHostMerged .= $domainVirtualHost['apacheBaseConfigWithSSL'] . "\n\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
file_put_contents('/etc/apache2/apache2.conf', $virtualHostMerged);
|
||
|
|
||
|
shell_exec('systemctl reload apache2');
|
||
|
}
|
||
|
|
||
|
}
|