Skip to content

Instantly share code, notes, and snippets.

@vanduc1102
Last active June 30, 2020 06:51
Show Gist options
  • Save vanduc1102/2183f2d3ddc92b1d6bb64342aa40bbab to your computer and use it in GitHub Desktop.
Save vanduc1102/2183f2d3ddc92b1d6bb64342aa40bbab to your computer and use it in GitHub Desktop.
Setup apache2 virtual hosts
SetEnv DB_USER root
SetEnv DB_PASSWORD test
SetEnv DB_HOST db
###### All content of apache2.config
Listen 7001
<VirtualHost *:7001>
DocumentRoot /var/www/html/api.local
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Listen 7002
<VirtualHost *:7002>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/a.local
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
#### in php file
# $_SERVER['DB_HOST']
# /etc/hosts
127.0.0.1 api.local
127.0.0.1 a.local
@vanduc1102
Copy link
Author

vanduc1102 commented Jun 1, 2020

If you are with Docker, Dont forget to map the port to the host
e.g:

"ports":
  - "7000-7100:7000-7100"

@vanduc1102
Copy link
Author

vanduc1102 commented Jun 30, 2020

Virtual Host configuration

<VirtualHost *:80>
    DocumentRoot /app/public
    <Directory "/app/public">
        AllowOverride all
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment