From 4d0ea376b666602481662970cdfb5c23169b9e80 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Tue, 14 May 2024 13:59:06 +0300 Subject: [PATCH] Create ApacheBuildOriginal.php --- web/app/VirtualHosts/ApacheBuildOriginal.php | 129 +++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 web/app/VirtualHosts/ApacheBuildOriginal.php diff --git a/web/app/VirtualHosts/ApacheBuildOriginal.php b/web/app/VirtualHosts/ApacheBuildOriginal.php new file mode 100644 index 0000000..a82c564 --- /dev/null +++ b/web/app/VirtualHosts/ApacheBuildOriginal.php @@ -0,0 +1,129 @@ +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 + + + Listen 443 + + + + Listen 443 + + + + Options FollowSymLinks + AllowOverride None + Require all denied + + + + AllowOverride None + Require all granted + + + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + + +AccessFileName .htaccess + + + Require all denied + + +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'); + } + +}