Skip to content

Instantly share code, notes, and snippets.

@mkeneqa
Created October 28, 2019 22:35
Show Gist options
  • Save mkeneqa/ecc941604ea05b6423d80f6490422618 to your computer and use it in GitHub Desktop.
Save mkeneqa/ecc941604ea05b6423d80f6490422618 to your computer and use it in GitHub Desktop.
Apache config for multiple virtual hosts (i.e. frontend and backend) on Local ( \etc\apache\sites-enabled\000-default.conf )
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /app/public/frontend/public
Header set Access-Control-Allow-Origin "*"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /app/public/backend/>
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
# This is to forward all PHP to php-fpm.
<IfModule mod_proxy_fcgi.c>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://unused-domain-string-but-required/"
</FilesMatch>
<Proxy fcgi://unused-domain-string-but-required>
ProxySet connectiontimeout=5 timeout=240
</Proxy>
# If the php file doesn't exist, disable the proxy handler.
# This will allow .htaccess rewrite rules to work and
# the client will see the default 404 page of Apache
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule (.*) - [H=text/html]
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
FcgidWrapper /usr/local/bin/php-wrapper .php
</IfModule>
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
</VirtualHost>
<VirtualHost *:8089>
ServerAdmin webmaster@localhost
DocumentRoot /app/public/backend/public
Header set Access-Control-Allow-Origin "*"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /app/public/frontend/>
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
# This is to forward all PHP to php-fpm.
<IfModule mod_proxy_fcgi.c>
<FilesMatch \.php$>
SetHandler "proxy:unix:/var/run/php-fpm.sock|fcgi://unused-domain-string-but-required/"
</FilesMatch>
<Proxy fcgi://unused-domain-string-but-required>
ProxySet connectiontimeout=5 timeout=240
</Proxy>
# If the php file doesn't exist, disable the proxy handler.
# This will allow .htaccess rewrite rules to work and
# the client will see the default 404 page of Apache
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule (.*) - [H=text/html]
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .php
FcgidWrapper /usr/local/bin/php-wrapper .php
</IfModule>
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment