mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 15:40:25 +00:00
94 lines
2.3 KiB
PHP
94 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\VirtualHosts;
|
|
|
|
use App\Models\Domain;
|
|
|
|
class ApacheBuild
|
|
{
|
|
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(false);
|
|
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');
|
|
}
|
|
|
|
}
|