<?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>Anorgan's blog about stuff &#187; subdomain</title> <atom:link href="http://blog.anorgan.com/tag/subdomain/feed/" rel="self" type="application/rss+xml" /><link>http://blog.anorgan.com</link> <description>...hmm</description> <lastBuildDate>Wed, 19 Oct 2011 07:49:33 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>Test projects viewer</title><link>http://blog.anorgan.com/2009/04/05/test-projects-viewer/</link> <comments>http://blog.anorgan.com/2009/04/05/test-projects-viewer/#comments</comments> <pubDate>Sun, 05 Apr 2009 21:58:14 +0000</pubDate> <dc:creator>Anorgan</dc:creator> <category><![CDATA[Linux]]></category> <category><![CDATA[Web]]></category> <category><![CDATA[bind9]]></category> <category><![CDATA[DNS]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[subdomain]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[wildcard]]></category><guid
isPermaLink="false">http://blog.anorgan.com/?p=202</guid> <description><![CDATA[I have a couple of test projects in my test directory. This is where I usually put the latest wordpress, phpBB or any other script or web software I would like to test out or develop and play with. Until recently I had to access those by writing the virtual host path (www.test.local) and then [...]]]></description> <content:encoded><![CDATA[<div
id="attachment_217" class="wp-caption alignleft" style="width: 310px"><a
class="thickbox" href="/wp-content/uploads/2009/04/test_environment.jpg"><img
class="size-medium wp-image-217" title="Test environment viewer" src="http://blog.anorgan.com/wp-content/uploads/2009/04/test_environment-300x224.jpg" alt="Test environment viewer" width="300" height="224" /></a><p
class="wp-caption-text">Test environment viewer</p></div><p>I have a couple of test projects in my test directory. This is where I usually put the latest wordpress, phpBB or any other script or web software I would like to test out or develop and play with. Until recently I had to access those by writing the virtual host path (www.test.local) and then append the directory name (in.eg. /drupal). I got tired of it, and coded a nifty little &#8220;browser&#8221; which displays all of the directories and files. Combined with the DNS wildcards, you can have unlimited virtual domains without having to configure them in vhosts, setting the /etc/hosts and restarting apache server. I have included this in the zip file found at the end of this post.</p><p>We are using bind dns server to resolve everything that comes to the &#8220;test&#8221; domain to your machines IP address. After that, Apache takes care of the rest. And what he does is kinda cool. The .htaccess file has a set of rules to test weather the index.php exists in the requested directory (via subdomain), and if it does, he redirects us to that directory. If the index.php doesn&#8217;t exist, our &#8220;main&#8221; index.php shows the contents of that directory, so you can select any other file and run it. Let&#8217;s start.</p><p><span
id="more-202"></span>Setting up your DNS server under Ubuntu is best described <a
title="Ubuntu DNS bind" href="http://rustykruffle.com/tech-stuff/ubuntu/how-i-got-networking-and-dns-to-work-in-ubuntu-intrepid/" target="_blank">here</a>. I will only display contents of my files, so you know what to do. My hostname (/etc/hostname) is &#8220;ubuntu&#8221; and IP address of my machine is 192.168.253, so when ever you see one of those, change to your settings. To install bind, use synaptic (search for bind9), to start, stop or restart bind, pass those commands to /etc/init.d/bind9, i.e. &#8220;/etc/init.d/bind9 stop&#8221;. To edit the files I used vi, and I also had to be root, so I ran sudo -i to become one.</p><p><strong>/etc/hosts</strong></p><blockquote><p><code> 192.168.1.253 ubuntu <br
/> 192.168.1.253 www.test.local test.local </code></p></blockquote><p><strong>/etc/bind/named.conf.local</strong></p><blockquote><p><code>acl "local" { <br
/> 192.168.1.0/24; <br
/> 127.0.0.1; <br
/> };<br
/> zone "test" {<br
/> type master;<br
/> file "/etc/bind/zones/db.test";<br
/> allow-query { local; };<br
/> notify no;<br
/> };<br
/> // For reverse DNS <br
/> zone "1.168.192.in-addr.arpa" {<br
/> type master;<br
/> file "/etc/bind/zones/rev.1.168.192.in-addr.arpa";<br
/> allow-query { local; };<br
/> };</code></p></blockquote><p><strong>/etc/bind/named.conf.options</strong></p><blockquote><p><code><br
/> options {<br
/> directory "/var/cache/bind";<br
/> forwarders {<br
/> 192.168.1.254;<br
/> };<br
/> auth-nxdomain no;    # conform to RFC1035<br
/> listen-on-v6 { any; };<br
/> };</code></p></blockquote><p><strong>/etc/bind/zones/db.test</strong></p><blockquote><p><code>$ORIGIN .<br
/> $TTL 86400      ; 1 day<br
/> test            IN SOA  test. (<br
/> 200904031  ; serial number (todays date appnded with '1')<br
/> 10800      ; refresh (3 hours)<br
/> 3600       ; retry (1 hour)<br
/> 604800     ; expire (1 week)<br
/> 86400      ; minimum (1 day)<br
/> )<br
/> $ORIGIN test.<br
/> @                       NS      ubuntu<br
/> ubuntu                  A       192.168.1.253 ;This is the hostname &amp; ip of my computer<br
/> test                    CNAME   ubuntu<br
/> *.test                  CNAME   ubuntu</code></p></blockquote><p><strong>/etc/bind/zones/rev.1.168.192.in-addr.arpa</strong></p><blockquote><p><code>$ORIGIN .<br
/> $TTL 86400      ; 1 day<br
/> 1.168.192.in-addr.arpa  IN SOA  test. (<br
/> 200904031  ; serial number (today's date appended with '1')<br
/> 28800      ; refresh (8 hours)<br
/> 14400      ; retry (4 hours)<br
/> 3024000    ; expire (5 weeks)<br
/> 86400      ; minimum (1 day)<br
/> )<br
/> $ORIGIN 1.168.192.in-addr.arpa.<br
/> @       NS      ubuntu<br
/> 253     PTR     ubuntu  ;The 253 is the last octet of my machines ip address</code></p></blockquote><p>After the bind has been set up, restart it, and test it. You should make a virtual host that points to www.test.test. Now, if you type anything else as subdomain, you should get the test.test page again. Try with something.test.test, or anythingelse.test.test.  For apache setup i have &#8220;NameVirtualHost 192.168.1.253&#8243; in the main config and use</p><blockquote><p><code><br
/> ServerName      test.test<br
/> ServerAlias     *.test.test<br
/> DocumentRoot    "/path/to/test"<br
/> </code></p></blockquote><p>for every subdomain i need.</p><p>We now have our environment set up, and need the contents of the test directory displayed. For that we use the index.php to list the directories and files. The directories are linked to be the subdomains. Now, if you do get to the directory which does not include index.php, it&#8217;s contents will be displayed, and you will be able to click the file you want to run. This is handled by .htaccess. If you type the wrong subdomain, you will get a notice about missing directory. I still didn&#8217;t get directories with uppercase letters or dots to display, but this is enough.</p><p>I also did a brief search for the theme, and used one to display the content, so it has the feeling of a finished project, not my usual html without the css or even parts of html without the html, head and body parts <img
src='http://blog.anorgan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Somehow I couldn&#8217;t justify using smarty here <img
src='http://blog.anorgan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , so i did str_replace to modify the content of the template. Here is the download link so you can put it in the /test dir and see all your projects. Tell me what you think of it.</p><blockquote><p><a
class="download" title="Test Environment" href="/wp-content/uploads/2009/04/test_environment.zip"></a><a
href="/wp-content/uploads/2009/04/test_environment.zip">Test environment viewer</a></p></blockquote> ]]></content:encoded> <wfw:commentRss>http://blog.anorgan.com/2009/04/05/test-projects-viewer/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: blog.anorgan.com @ 2012-02-04 21:55:01 -->
