How to setup virtualhost in Mac OS X 10.9.1 Maverick

Submitted by admin on Thu, 02/06/2014 - 21:06

In case you are not using MAMP, you might need this tip whether if you want to avoid the killer "Forbidden" message when you try to access to document root :)

1. Go to

<code>
sudo nano /etc/apache2/httpd.conf
</code>

and uncomment line number 478

<code>
Include /private/etc/apache2/extra/httpd-vhosts.conf
</code>

2. Go to

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

y put something like

<code>
<VirtualHost *:80>
ServerAdmin a.sanchez75@gmail.com
DocumentRoot "/Library/Webserver/Documents/mtnforum7/"
ServerName www.mtnforum.org
ErrorLog "/private/var/log/apache2/mtnforum.org-error_log"
CustomLog "/private/var/log/apache2/mtnforum.org-access_log" common
<Directory /Library/Webserver/Documents/mtnforum7/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
</code>

3. If you need redirect a domain, go to

<code>
nano /etc/hosts
</code>

y put inside something like

<code>
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 infoandina.mtnforum.org www.mtnforum.org
</code>

Etiquetas