Computersnyou

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

Posted on  1/8/2014

VirtualHost is a term refers to hosting Multiple WebSites in same Web Server , like hosting “example.com ” and example.org 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

EnableVirtualHost
EnableVirtualHost

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"
        ServerName example.com
        ServerAlias www.example.com
        ErrorLog "/private/var/log/apache2/example.com"
        CustomLog "/private/var/log/apache2/example.com" common

        # Other directives here

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

</VirtualHost>

setup

VhostConf
VhostConf

Now setup Host File to point at localhost as example.com

open /etc/hosts

sudo nano /etc/hosts
and add
 127.0.0.1 example.com

 

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

Screen Shot 2014-01-08 at 10.58.03 pm
Screen Shot 2014-01-08 at 10.58.03 pm

for any kind of discussion and help join our forum .


  • Home
  • About