jcadima
11/8/2015 - 6:20 PM

Virtual Host setup on Mac

Virtual Host setup on Mac

REF: 
http://jonathannicol.com/blog/2012/03/11/configuring-virtualhosts-in-xampp-on-mac/

 http://gwaphic.com/poet/setting-up-virtual-hosts-with-xampp-5-6-3-0-on-mac-osx-yosemite/

THIS GUIDE:
https://www.tech-otaku.com/local-server/configuring-virtual-hosts-xampp-mac-os-x/

#################  EDIT THESE FILES #####################
1) sudo vim /Applications/XAMPP/xamppfiles/etc/httpd.conf
Uncomment the Include:
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf


2) 
sudo vim /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf

add the following:
# localhost
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
    <Directory "/Applications/XAMPP/xamppfiles/htdocs">
        Options Indexes FollowSymLinks Includes execCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

This step is necessary to ensure that http://localhost still points at XAMPP’s htdocs directory once we’ve created our custom VirtualHosts


Now you can add custom virtualHosts at the bottom of the vhosts file:

# My custom host
<VirtualHost *:80>
    ServerName jcadima.dev
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/jcadima"
    <Directory "/Applications/XAMPP/xamppfiles/htdocs/jcadima">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog "logs/mysite.local-error_log"
</VirtualHost>
 
##################  IMPORTANT ################# 
comment the 2 virtualhosts  for dummysite2 and also remove the ErrorLog line 
if there are errors on apache server


#################  LAST STEP: ################# 
sudo vim /etc/hosts
add the following

127.0.0.1  jcadima.dev # this is the name of the ServerName 
127.0.0.1  laramcms.dev  # another one

now go to http://jcadima.dev and it will load the files from xampp htdocs jcadima directory