<?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>Ivansmusings.com &#187; Apache Virtual Domains</title>
	<atom:link href="http://ivansmusings.com/archives/tag/apache-virtual-domains/feed" rel="self" type="application/rss+xml" />
	<link>http://ivansmusings.com</link>
	<description></description>
	<lastBuildDate>Wed, 13 Jul 2011 07:27:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Creating Virtual Domains Under Apache</title>
		<link>http://ivansmusings.com/archives/320</link>
		<comments>http://ivansmusings.com/archives/320#comments</comments>
		<pubDate>Sun, 19 Oct 2008 00:02:48 +0000</pubDate>
		<dc:creator>ivansmus</dc:creator>
				<category><![CDATA[Apache Virtual Domains]]></category>
		<category><![CDATA[Creating Virtual Domains]]></category>

		<guid isPermaLink="false">http://ivansmusings.com/?p=320</guid>
		<description><![CDATA[When Apache is installed on a M.S. Windows XP / Vista computer the Apache installer places Apache’s file structure in: C:\Program Files\Apache Group\Apache2 Apache’s index file, which is displayed when http://localhost is typed into a Browser window and the Go button or the Enter key is pressed, resides in: C:\Program Files\Apache Group\Apache2\htdocs If you do [...]]]></description>
			<content:encoded><![CDATA[<p>When Apache is installed on a M.S. Windows XP / Vista computer the Apache installer places Apache’s file structure in<strong>:</strong></p>
<p>C:\Program Files\Apache Group\Apache2</p>
<p>Apache’s index file, which is displayed when http://localhost is typed into a Browser window and the Go button or the Enter key is pressed, resides in<strong>:</strong></p>
<p>C:\Program Files\Apache Group\Apache2\htdocs</p>
<p>If you do not want Apaches default index page to be displayed when http://localhost is typed in a Browser’s address bar and the <strong>Go</strong> button or the <strong>Enter</strong> key is pressed, simply create your own HTML file, name it index.html and place this in<strong>: </strong></p>
<p>C:\Program Files\Apache Group\Apache2\htdocs</p>
<p>Now if you enter http://localhost in a Browser’s address bar and press Go or the Enter key your HTML page will be rendered in the Browser’s window.</p>
<p>This is an indication that Apache is working perfectly.</p>
<p>Having said that, it’s definitely not good practice to place all your website’s resources within the folder that Apache uses for its own resources i.e.:</p>
<p>C:\Program Files\Apache Group\Apache2\htdocs</p>
<p>It’s good programming practice to keep your website’s resources separate from Apache’s internal resources.</p>
<p>All that is required is that you create a separate folder, anywhere on your hard disk and place your website resources within that folder.</p>
<p>For example:<strong> d:\mysite</strong></p>
<p>Now all that remains is that Apache needs to be informed that the folder<strong>d:\mysite</strong> is where you’ve loaded all your website’s resources.</p>
<p>You do this by creating a <strong>Virtual Domain</strong> under Apache and binding this domain to the folder where your website’s resources are placed.</p>
<p>To create a virtual domain you have to make changes within Apache’s <strong>httpd.conf</strong> file.</p>
<p>Apache’s httpd.conf file is resides in<strong>:</strong></p>
<p>C:\Program Files\Apache Group\Apache2\conf</p>
<p>Navigate to that folder and the first thing to do is to make a copy of Apache’s httd.conf file and save this within Apache’s conf folder i.e. <strong>httpd_copy.conf</strong>.</p>
<p>This way if you’ve made some errors when adding a virtual domain to the httpd.conf file and Apache stops working, all you have to do is to overwrite Apache’s httpd.conf file with the copy you’ve made, then ensure that the file is re-named httpd.conf and Apache should start up again.</p>
<p><strong>NOTE:</strong> In case you do not keep a copy of Apache’s httpd.conf and you’ve damaged the original httpd.conf file you have to re-install Apache from scratch, to get a working copy of Apache web server.</p>
<p>Now open the httpd.conf file in your favorite ASCII editor, (Notepad would do just fine). Scroll right down to the end of the httpd.conf file and you will notice Apache’s virtual domain example.</p>
<p>The code there should look something like<strong>:</strong></p>
<p>#<strong>NameVirtualHost </strong>*:80</p>
<p>#VirtualHost example<strong>:</strong><br />
 # Almost any Apache directive may go into a VirtualHost container.<br />
 # The first VirtualHost section is used for requests without a known<br />
 # server name.<br />
 #<virtualhost><br />
 # ServerAdmin webmaster@dummy-host.example.com<br />
 # DocumentRoot /www/docs/dummy-host.example.com<br />
 # ServerName dummy-host.example.com<br />
 # ErrorLog logs/dummy-host.example.com-error_log<br />
 # CustomLog logs/dummy-host.example.com-access_log common<br />
 # </virtualhost><br />
 # <strong></strong></p>
<p>The <strong>NameVirtualHost</strong> and <strong>VirtualHost</strong> directives are what we are interested in.</p>
<p>Simply copy the whole lot from <strong># NameVirtualHost </strong>to<strong></strong> and paste this below the original code.</p>
<p>Then <strong>delete</strong> the <strong>#</strong> which appears before each entry as shown below.</p>
<p><em>Please notice the section where the <strong>#</strong> are <strong>not deleted</strong>.</em></p>
<p>NameVirtualHost *:80</p>
<p># VirtualHost example:<br />
 # Almost any Apache directive may go into a VirtualHost container.<br />
 # The first VirtualHost section is used for requests without a known<br />
 # server name.</p>
<p><virtualhost *:80><br />
 ServerAdmin webmaster@dummy-host.example.com<br />
 DocumentRoot /www/docs/dummy-host.example.com<br />
 ServerName dummy-host.example.com<br />
 ErrorLog logs/dummy-host.example.com-error_log<br />
 CustomLog logs/dummy-host.example.com-access_log common<br />
 </virtualhost></p>
<p><strong>Next:</strong></p>
<p>Change<br />
 NameVirtualHost *:80</p>
<p>To read as:<br />
 NameVirtualHost 127.0.0.1:80</p>
<p>Notice that the <strong>#</strong> has been deleted <br />
 And <br />
 The local host ip <strong>127.0.0.1</strong> has replaced the <strong>*</strong> in this entry</p>
<p>Now let’s take a look at the <virtualhost </VirtualHost> XML segment.</virtualhost></p>
<p><virtualhost 127.0.0.1:80><br />
 ServerAdmin ivan@ivanbayross.com<br />
 DocumentRoot d:\mysite<br />
 ServerName www.mysite.com<br />
 ErrorLog d:\mysite\errors\errorlog<br />
 </virtualhost></p>
<p>Notice that the<strong>:</strong><br />
 <strong>ServerAdmin</strong> has a legitimate Email ID bound to it.<br />
 <strong>DoumentRoot</strong> has the physical path to your websites resources<br />
 <strong>ServerName</strong> can have any name bound to it, I’ve chosen <em>www.mysite.com<br />
 </em><strong>ErrorLog </strong>has the path to where Apache can keep its error log file</p>
<p><strong>NOTE:</strong> Do not forget to create the folder <strong>d:\mysite\errors</strong>. Then using Notepad create an empty file named <strong>errorlog</strong> within this folder.  <em>Please notice the absence of any file extension.</em></p>
<p>Save the httpd.conf you’ve been editing and re-start Apache.</p>
<p>To restart Apache simply <strong>right </strong>click on the <img src="http://www.ivansmusings.com/wp-includes/images/apache/virtualdomains/apacheicon.gif" alt="" /> icon in the task bar and a popup window will appear as shown in diagram 1.</p>
<table border="0" cellspacing="0" cellpadding="0" width="45%">
<tbody>
<tr>
<td align="left" valign="top"><img src="http://www.ivansmusings.com/wp-includes/images/apache/virtualdomains/apachemenu.gif" alt="" /></td>
</tr>
<tr>
<td>Diagram 1</td>
</tr>
</tbody>
</table>
<p>Click on Open Apache Monitor and a popup window will appear as shown in diagram 2</p>
<table border="0" cellspacing="0" cellpadding="0" width="65%">
<tbody>
<tr>
<td align="left" valign="top"><img src="http://www.ivansmusings.com/wp-includes/images/apache/virtualdomains/apacherestart.gif" alt="" /></td>
</tr>
<tr>
<td align="left">Diagram 2</td>
</tr>
</tbody>
</table>
<p>Simply click the Restart button.  If all is well Apache will startup perfectly.</p>
<p>There’s a few more steps to be carried out to check is you’ve created the Virtual domain correctly, they are<strong>:</strong><br />
 Making an entry in the <strong>hosts</strong> file.<br />
 Using the file Browser navigate to the folder C:\Windows\System32\drivers\etc<br />
 Within this folder there will be a file called <strong>hosts</strong>.</p>
<p><strong>NOTE:</strong> If you have never used the hosts file ever before then you will find a file called <strong>hosts.sam</strong> or <strong>hosts.tmp</strong> in this folder. Copy this file to a file named <strong>hosts</strong> and you are done.  Then <strong>edit</strong> the contents of <strong>hosts</strong> as indicated below.</p>
<p># Copyright (c) 1993-2006 Microsoft Corp.<br />
 #<br />
 # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.<br />
 #<br />
 # This file contains the mappings of IP addresses to host names. Each<br />
 # entry should be kept on an individual line. The IP address should<br />
 # be placed in the first column followed by the corresponding host name.<br />
 # The IP address and the host name should be separated by at least one<br />
 # space.<br />
 #<br />
 # Additionally, comments (such as these) may be inserted on individual<br />
 # lines or following the machine name denoted by a &#8216;#&#8217; symbol.<br />
 #<br />
 # For example:<br />
 #<br />
 #      102.54.94.97     rhino.acme.com          # source server<br />
 #       38.25.63.10     x.acme.com              # x client</p>
<p><strong>NOTE:</strong> Between the ip and the site name you must use the <strong>Tab</strong> key.</p>
<p># For example:<br />
 #      102.54.94.97     rhino.acme.com          # source server<br />
 #       38.25.63.10     x.acme.com              # x client host</p>
<p>127.0.0.	www.mysite.com</p>
<p>Save hosts and exit.</p>
<p>Finally place a unique index.html file within the folder d:\mysite.  Now when you enter the URL in the Browser address bar: <strong>http://www.mysite.com</strong> Apache will display the contents of the index.html file you’ve place in the folder d:\mysite.</p>
<p>If all this works perfectly then you can build the rest of your website within the folder d:\mysite</p>
]]></content:encoded>
			<wfw:commentRss>http://ivansmusings.com/archives/320/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

