Edit the hosts file to add a local DNS entry.
![](http://farm4.static.flickr.com/3447/3913882218_297cde0cda_o.png)
Add the domain name you wish to use 127.0.0.1 is the loopback IP do not change this IP.
![](http://farm3.static.flickr.com/2504/3913882188_16ee189691_o.png)
Create the folders and files for the local website. I chose to place the log files for apache in the site folder and the website content under a sub folder www.
![](http://farm3.static.flickr.com/2637/3913094891_184e374041_o.png)
Edit httpd.conf I used path finder here to show the locations.
![](http://farm3.static.flickr.com/2435/3913094715_79edee0351_o.png)
You can also use VI or any text editor
![](http://farm3.static.flickr.com/2674/3913094751_e5a1cde8d0_o.png)
On line 465 uncomment: Include /private/etc/apache2/extra/httpd-vhosts.conf and save the file.
![](http://farm3.static.flickr.com/2569/3913094655_049ac4ab3b_o.png)
Edit: /etc/apache2/extra/httpd-vhosts.conf
![](http://farm3.static.flickr.com/2609/3913881936_74f9315f63_o.png)
Add in the details of the new virtual host and save:
( I'm running Railo on Tomcat locally so I have so additional parameters )
I also set my logging levels to log as much as possible.
Notice the location of the logs files matched the access.log and error.log files created earlier
![](http://farm3.static.flickr.com/2492/3913095163_c7084ab85c_o.png)
Run: apachectl -t
to confirm there are no syntax errors.
I choose to leave the example sites, they cause a warning but it wont stop apache.
Then restart apache: sudo apachectl restart
![](http://farm3.static.flickr.com/2621/3913881994_c92bfa5cc2_o.png)
Create a test file in the new folder for the virtual host ( /Users/Paul/Sites/paulsDev/www )
![](http://farm3.static.flickr.com/2650/3913095347_2c85950240_o.png)
Confirm the new virtual host works:
![](http://farm4.static.flickr.com/3499/3913882344_1fbfdfd460_o.png)
If you'd like to watch the logs in a terminal you can use tail:
tail -f /the/Path/to/the/log/file
![](http://farm4.static.flickr.com/3511/3913929914_1b65852184_o.png)
BTW Dave made a great How-to on setting up Tomcat and Railo on OSX which you can view here.
uhm, excuse me. Wow
ReplyDeleteTHanks so much! I have been wrestling with this for a few days. Do your .htacces files work under this setup? I still can't get mine to engage eventhough I now have the virtual hosts in place. Thanks again
ReplyDeleteGood question. Locally I am not using mod_rewrite but you will need to add this block when defining the vhost:
ReplyDelete%Directory /Users/Paul/Sites/paulsDev/www%
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
%/Directory%
*note I swapped % for <
you saved my life.
ReplyDeleteHi there,
ReplyDeleteI have no Include /private/etc/apache2/extra/httpd-vhosts.conf
What do I do
Try this:
ReplyDeletesudo vi /etc/apache2/extra/httpd-vhosts.conf