How to setup Apache VirtualHost in MacOSX 10.9 Step by Step [ How To ]

VirtualHost is a term refers to hosting Multiple WebSites in same Web Server , like hosting “ ” and in same server . In this tutorial i will show you how to setup  NameBased Virtual server in MacOSX .  You Just Have to configure Your  hosts file to map each hostname to the same  IP address and then configure the Apache HTTP Server to recognize the different hostnames.

Just follow simple Steps .

Enable Virtual Hosts

Open “ /etc/apache2/httpd.conf 

open terminal

sudo nano /etc/apache2/httpd.conf

Find Virtual Host include line and Uncomment  ( remove # sign from front ) that line

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf


Setup Virtual Host 

Save that file . and open  /etc/apache2/extra/httpd-vhosts.conf File

NameVirtualHost *:80

<VirtualHost *:80>

        ServerAdmin [email protected]
        DocumentRoot "/Users/alok/Sites/example"
        ErrorLog "/private/var/log/apache2/"
        CustomLog "/private/var/log/apache2/" common

        # Other directives here

        <directory "/Users/alok/Sites/example">
                Options Indexes MultiViews FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all



Now setup Host File to point at localhost as

open /etc/hosts

 sudo nano /etc/hosts
 and add


and restart the web server open terminal and type sudo apachectl restart then open browser and open . now will point at your local web server .

Screen Shot 2014-01-08 at 10.58.03 pm

for any kind of discussion and help join our forum .

Tagged With : -
Add Comment