<?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>Roshan Kulkarni &#187; Apache</title>
	<atom:link href="http://roshankulkarni.info/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://roshankulkarni.info</link>
	<description>On Technology, Web and Consulting</description>
	<lastBuildDate>Sun, 30 May 2010 18:28:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Setting up an Apache2 Virtual Host for a Subdomain</title>
		<link>http://roshankulkarni.info/2009/09/setting-up-apache2-virtual-host-for-your-project/</link>
		<comments>http://roshankulkarni.info/2009/09/setting-up-apache2-virtual-host-for-your-project/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 06:29:36 +0000</pubDate>
		<dc:creator>roshan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://roshankulkarni.info/?p=47</guid>
		<description><![CDATA[I&#8217;ve done this several times before, so noting it for my own quick reference. This might be of help to others finding their way around Apache deployments. I&#8217;ve tried this on a Ubuntu 9.04 (Jaunty Jackalope) with Apache2. Here is what we are trying to setup: Subdomain for your web project: http://mysubdomain.mydomain.com (say, http://staging.mykillerapp.com) You [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve done this several times before, so noting it for my own quick reference. This might be of help to others finding their way around Apache deployments.</p>
<p>I&#8217;ve tried this on a Ubuntu 9.04 (Jaunty Jackalope) with Apache2. Here is what we are trying to setup:</p>
<ul>
<li>Subdomain for your web project: <em>http://mysubdomain.mydomain.com (say, http://staging.mykillerapp.com)<br />
</em></li>
</ul>
<ul>
<li>You wish to give restricted access to a people in your team, to deploy the project. You don&#8217;t wish to give them sudo or admin rights to your Linux box.</li>
</ul>
<p><strong>Creating a Sub-domain</strong></p>
<p>Your hosting provider is likely to give you a web-based domain management tool (CPanel or something else). Add a DNS &#8220;A record&#8221; as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">subdomain      PUBLICIPADDRESS      A</pre></div></div>

<p>For example:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">staging      x.x.x.x      A</pre></div></div>

<p><strong>Create a non-root user account to manage your application</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ adduser staging</pre></div></div>

<p>I&#8217;m assuming that staging home is the usual <em>/home/staging</em>. Lets create a <em>www </em>under it, which will serve as the root directory for our virtual host<em> /home/staging/www/</em></p>
<p><strong>Enable the Apache Virtual Host Module</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod vhost_alias</pre></div></div>

<p><strong>Create a virtual host configuration for Apache2</strong></p>
<p>Apache2 tracks the virtual hosts configurations in this location:<em> /etc/apache2/sites-available/.</em> There will be a default config file; Lets make a copy of that file at the same directory location.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> default staging
$ <span style="color: #c20cb9; font-weight: bold;">vi</span> staging</pre></td></tr></table></div>

<p>Make your virtual host file look like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;VirtualHost</span> *:80<span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
        ServerName staging.mykillerapp.com
        ServerAdmin appadmin@mykillerapp.com
        DocumentRoot /home/staging/www/
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Directory</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                Options FollowSymLinks
                AllowOverride All
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Directory</span> /home/staging/www<span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                Options FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        ErrorLog /var/log/apache2/error.log
&nbsp;
        # Possible values include: debug, info, notice, 
        # warn, error, crit, alert, emerg.
        LogLevel warn
&nbsp;
        CustomLog /var/log/apache2/access.log combined
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><strong>Enable your virtual host</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite staging</pre></div></div>

<p>This sets up a soft-link in <em>/etc/apache2/sites-enabled/</em> which points to your virtual host config file.</p>
<p><strong>Finally, restart apache</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> service apache2 restart</pre></div></div>

<p style="text-align: left;"><em>Hit your virtual host <em>at http://staging.mykillerapp.com</em></em></p>
]]></content:encoded>
			<wfw:commentRss>http://roshankulkarni.info/2009/09/setting-up-apache2-virtual-host-for-your-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

