How to enable and setup virtual-host in MacOSX 10.10 Yosemite

This guide is part of tutorials series related to full development environment setup , previously I posted about how to enable Apache and PHP in Mac OS X : See here .

For MacOSX 10.9 Users :


edit /etc/apache2/httpd.conf

sudo nano /etc/apache2/httpd.conf

and uncomment Include /private/etc/apache2/extra/httpd-vhosts.conf Line ( remove # from starting of the line )

Then edit /etc/apache2/extra/httpd-vhosts.conf

 # Virtual Hosts
 # Required modules: mod_log_config

 NameVirtualHost *:80

 <VirtualHost *:80>
 DocumentRoot "/Users/alok/Sites/example"
 <directory "/Users/alok/Sites/example">
 Options Indexes MultiViews FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all
 ErrorLog "/private/var/log/apache2/"
 CustomLog "/private/var/log/apache2/" common

Example :


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-07-14 at 12.35.00 pm

Tagged With : - -