<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Greymass - Exploring Everything &#187; Apache</title>
	<atom:link href="http://www.greymass.com/category/programming/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.greymass.com</link>
	<description>Web Development, Design, PHP and random musings</description>
	<lastBuildDate>Wed, 25 Aug 2010 16:22:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting up Local VirtualHosts with Apache (Including XAMPP or WAMP)</title>
		<link>http://www.greymass.com/setting-up-local-virtualhosts-with-apache-including-xampp-or-wamp/</link>
		<comments>http://www.greymass.com/setting-up-local-virtualhosts-with-apache-including-xampp-or-wamp/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 18:39:34 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Hosts File]]></category>
		<category><![CDATA[Organization]]></category>
		<category><![CDATA[Project Management]]></category>
		<category><![CDATA[VirtualHosts]]></category>

		<guid isPermaLink="false">http://www.greymass.com/?p=135</guid>
		<description><![CDATA[Working with local development copies of websites can get to be a bit messy after a period of time, especially when you are developing work applications and personal applications on the same machine. So I figured I would share the method that I use to keep everything organized on my machine, and on my previous [...]]]></description>
			<content:encoded><![CDATA[<p>Working with local development copies of websites can get to be a bit messy after a period of time, especially when you are developing work applications and personal applications on the same machine. So I figured I would share the method that I use to keep everything organized on my machine, and on my previous development machines. The focus of this article will be on Windows Machines running XAMPP or WAMP (or even straight apache).<br />
<span id="more-135"></span></p>
<h2>The Idea</h2>
<p>When developing websites, sometimes switching between different environments will break the URL Schema that your website is using. If you are referencing things from your website relative to the root (ie. an image path being /images/image.png) and you are running development of that website on your machine from a subdirectory of your webroot, it won&#8217;t obviously load. The paths sometimes get skewed and difficult to debug. So my personal schema is as follows:</p>
<p>(Using greymass.com as an example)<br />
Live Website: www.greymass.com<br />
Testing Website: qa.greymass.com<br />
Local Development: greymass.local</p>
<p>Using a structure like this, lets you develop everything as if it was on the root folder of the website. It lets you always reference the root even if it is in a subfolder. Well how do we accomplish this? With VirtualHosts.</p>
<h2>Step #1 &#8211; Your HOSTS File</h2>
<p>Now, if you have a better way to accomplish this or a small program or anything, feel free to share. This is just the method I have been using to redirect traffic, I am not stating it&#8217;s the best, its just the method I use personally. </p>
<p>Every computer has a HOSTS file, Windows, *nux, and OS X. This file is a simple tab-delimited file which points a HOSTNAME to an IP ADDRESS. If you were to open your hosts file right now, you&#8217;d probably see one entry:</p>
<pre name="code" class="php">
127.0.0.1        localhost
</pre>
<p>This file is located in a few different areas. </p>
<p><strong>Windows</strong> Hosts File: C:\Windows\System32\drivers\etc\hosts</p>
<p>This file under windows is protected by the operating system, so to edit this in windows, you are going to need administrative privileges. Once you find it and get it open, to add a new &#8220;VirtualHost&#8221;, simply enter a new line of code, the IP address, tab, then the hostname you&#8217;d like to give it. I&#8217;ll continue on with my example for greymass.com and greymass.local.</p>
<pre name="code" class="php">
127.0.0.1        greymass.local
</pre>
<p>What this does, is it tells <strong>THIS</strong> computer (not the rest of the world) that when you type &#8220;greymass.local&#8221; in your web browser, to goto the IP address listed in the file and pass &#8220;greymass.local&#8221; as the header. If you tried it right now, it would pull up the default instance of whatever website is on your local machine, because we haven&#8217;t told the web server what to do with that now.</p>
<h2>Step #2 &#8211; Your Apache VHosts Config</h2>
<p>On a Windows machine, I&#8217;ve used Apache, XAMPP and WAMP to run a bundled apache/mysql/php config, and it works rather well. They are all easy to install and get you started right away. These two programs however are a bit different when it comes to how they hide their config files for apache, so I will break this apart off the bat. </p>
<p><strong>For Stand-Alone Apache:</strong><br />
If you installed Apache into the default folder (&#8220;C:\Program Files\&#8221;), it would be located someplace like this:<br />
C:\Program Files\Apache\Apache2.2.8\conf\extra\httpd-vhosts.conf</p>
<p><strong>For WAMP Users:</strong><br />
If you installed WAMP into the default folder (&#8220;C:\Program Files\&#8221;), it would be located someplace like this:<br />
C:\Program Files\Wamp\bin\apache\apache2.2.8\conf\extra\httpd-vhosts.conf</p>
<p><strong>For XAMPP Users:</strong><br />
If you installed XAMPP to its default location, it should be sitting on &#8220;C:\Xampp&#8221;, which is pretty easy to locate.<br />
C:\Xampp\apache\conf\extra\httpd-vhosts.conf</p>
<p>Now once you&#8217;ve found this file, you probably will notice there is a bunch of commented code throughout the file. This stuff has some pretty good documentation, as well as some examples of how to use the VirtualHosts.  First things first, you are going to want to uncomment the line as follows:</p>
<pre name="code" class="php">
## NameVirtualHost *:80
</pre>
<p>To uncomment it, simply remove the two pound (#) symbols in front of it. This line of code is telling the machine that this server is going to attempt to accept any VirtualHost requests on any IP, through port 80. After you uncomment it, the line of code should look as follows:</p>
<pre name="code" class="php">
NameVirtualHost *:80
</pre>
<p>You will see some examples below this line of code as well, but they have some extra stuff in them we really don&#8217;t need for development purposes. The simplest form of a VirtualHost entry is going to be as follows:</p>
<pre name="code" class="php">
&lt;VirtualHost *:80>
   DocumentRoot C:\Path\to\your\docroot
   ServerName greymass.local
&lt;/VirtualHost>
</pre>
<p>Now, save this file to its original location, you are going to want to overwrite the file. Once the file is saved, restart Apache through the XAMPP or WAMP control panel, and you now should be good to go. Try loading up your domain.local in your web browser (greymass.local) if you are using this as an example, and it should load up your web page!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.greymass.com/setting-up-local-virtualhosts-with-apache-including-xampp-or-wamp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

