Skip to content

Instantly share code, notes, and snippets.

@ahmadshuami
Last active January 7, 2022 14:43
Show Gist options
  • Save ahmadshuami/502a0043d946279a325ea94054620d0e to your computer and use it in GitHub Desktop.
Save ahmadshuami/502a0043d946279a325ea94054620d0e to your computer and use it in GitHub Desktop.
How to Setup Apache, PHP 8.0, MariaDB and Apache Virtual Host using Homebrew Part 4 - Apache Virtual Host
Watch the video at https://youtu.be/_CBqrrh85YY
1. Open apache config file
% subl /usr/local/etc/httpd/httpd.conf
2. Uncomment the following line
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
3. Open vhosts file
% subl /usr/local/etc/httpd/extra/httpd-vhosts.conf
4. Add the following settings
<VirtualHost *:80>
DocumentRoot "/Users/shuami/Sites"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/shuami/Sites/app_01"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/shuami/Sites/app_02"
ServerName localhost
</VirtualHost>
5. Update hosts file
% subl /etc/hosts
6. Add the following lines
127.0.0.1 localhost
127.0.0.1 app-01.test
127.0.0.1 app-02.test
7. Create file in app_01 and app_02 folder
8. Check apache config
% apachectl configtest
9. Restart apache
% brew services restart httpd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment