Vitural Host

I was trying to set up a virtual host with Apache on my MacBook and it turned out to be a bigger deal than I thought it would be.

Here are the steps that I took to setup “something.local”

First add a alias name to the mac os.
1) Open terminal Applications/Utilites/Terminal
2) Type “sudo nano /etc/hosts” (without quotes) and enter your password
3) Go to the end of the file using the arrow keys and add to the file “127.0.0.1 something.local” (without quotes)
4) Control X (Not apple key Control) , The “Y” key and enter
5) Now another config file type “sudo nano /etc/apache2/httpd.conf”
6) Go to the end of the File and add
NameVirtualHost *:80

< virtualhost *:80>
ServerAdmin someone@example.com
DocumentRoot “/Users/YOUR_USER_NAME/Sites/something.local”
ServerName something.local
ServerAlias www.something.local
< /virtualhost>

After restarting the computer when you type in “something.local” in to your web browser Apache will try to server up the index file in the something.local in you sites folder

Leave a Reply

Your email address will not be published. Required fields are marked *