mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-21 23:20:24 +00:00
Create ApacheBuildOriginal.php
This commit is contained in:
parent
469a6c8c43
commit
4d0ea376b6
1 changed files with 129 additions and 0 deletions
129
web/app/VirtualHosts/ApacheBuildOriginal.php
Normal file
129
web/app/VirtualHosts/ApacheBuildOriginal.php
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?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');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue