<?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>themattharris.com</title>
	<atom:link href="http://themattharris.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://themattharris.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 04 Jan 2010 17:35:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iTunes says &quot;there was a problem downloading  you do not have enough access privileges&quot;</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F07%2Fitunes-says-there-was-a-problem-downloading-you-do-not-have-enough-access-privileges%2F&amp;seed_title=iTunes+says+%26quot%3Bthere+was+a+problem+downloading++you+do+not+have+enough+access+privileges%26quot%3B</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F07%2Fitunes-says-there-was-a-problem-downloading-you-do-not-have-enough-access-privileges%2F&amp;seed_title=iTunes+says+%26quot%3Bthere+was+a+problem+downloading++you+do+not+have+enough+access+privileges%26quot%3B#comments</comments>
		<pubDate>Fri, 03 Jul 2009 10:01:56 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[macos]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[permissions]]></category>

		<guid isPermaLink="false">http://themattharris.com/?p=333</guid>
		<description><![CDATA[This week was one of those times where I needed to reinstall Leopard on my MacBook Pro. This is something which I do every now and then to make sure the development work i&#8217;ve doing hasn&#8217;t completely messed up my system. Normally this goes very well but this time iTunes decided to misbehave. 

The symptoms


You [...]]]></description>
			<content:encoded><![CDATA[<p>This week was one of those times where I needed to reinstall Leopard on my MacBook Pro. This is something which I do every now and then to make sure the development work i&#8217;ve doing hasn&#8217;t completely messed up my system. Normally this goes very well but this time iTunes decided to misbehave. <span id="more-333"></span></p>

<h2>The symptoms</h2>

<ul>
<li>You try and listen to some songs and you get asked to authorise the computer. You do this but the next song owned by the same account asks you to authorise again.</li>
<li>When you try and update applications for your iPhone you get an error -5000 on the downloads page</li>
<li>As with the appstore, you get an error -5000 when podcasts are being downloaded.</li>
</ul>

<h2>The problem</h2>

<p>This is such a trivial problem that it took a little while to work out what was going on. What&#8217;s happening is iTunes is unable to modify any of it&#8217;s files because of the permissions on the iTunes folders.</p>

<h2>The solution</h2>

<p>If your iTunes library is stored on an external hard drive (mine is), you can tell Finder to ignore permissions on the drive. To do this:</p>

<ul>
<li>Click on the drive in Finder</li>
<li>Choose <code>File -&gt; Get Info</code> (or press Command-I)</li>
<li>In the bottom right of the information panel that appears, check the padlock is unlocked.</li>
<li>If it isn&#8217;t unlocked, click it and enter your logon password</li>
<li>Put a tick in the <code>ignore ownership on this volume</code> box</li>
</ul>

<p>Alternatively, if your iTunes library is in your Music folder:</p>

<ul>
<li>Select your Music folder in Finder</li>
<li>Choose <code>File -&gt; Get Info</code> (or press Command-I)</li>
<li>In the bottom right of the information panel that appears, check the padlock is unlocked.</li>
<li>If it isn&#8217;t unlocked, click it and enter your logon password</li>
<li>At the bottom of the information panel click on the gear icon</li>
<li>Choose <code>Apply to enclosed items</code> &#8211; know this can take a while if your library is large</li>
</ul>

<p>You should now find iTunes is working again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F07%2Fitunes-says-there-was-a-problem-downloading-you-do-not-have-enough-access-privileges%2F&amp;seed_title=iTunes+says+%26quot%3Bthere+was+a+problem+downloading++you+do+not+have+enough+access+privileges%26quot%3B/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using local mail (/var/mail/user)</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F06%2Fusing-local-mail-varmailuser%2F&amp;seed_title=Using+local+mail+%28%2Fvar%2Fmail%2Fuser%29</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F06%2Fusing-local-mail-varmailuser%2F&amp;seed_title=Using+local+mail+%28%2Fvar%2Fmail%2Fuser%29#comments</comments>
		<pubDate>Tue, 16 Jun 2009 10:06:37 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[movemail]]></category>
		<category><![CDATA[sendmail]]></category>

		<guid isPermaLink="false">http://themattharris.com/?p=325</guid>
		<description><![CDATA[When developing websites it is quite common for there to be some kind of contact form or other mailing function.  The problem is that should you, like me, have your email being forwarded through Google Mail you will find those emails never get to your Google address.  The reason for this is simple, [...]]]></description>
			<content:encoded><![CDATA[<p>When developing websites it is quite common for there to be some kind of contact form or other mailing function.  The problem is that should you, like me, have your email being forwarded through Google Mail you will find those emails never get to your Google address.  The reason for this is simple, your computer is not recognised as a legitimate SMTP server so Google rejects the mail.  The good news is you can instead tell your Website to send the emails to your local computer instead.<span id="more-325"></span></p>

<p>Very simply you just need to give the website you are testing the email address <code>username@computername.local</code>. For example my username is <code>matt</code> and my computer is called <code>tribble-mbp</code> so my email would be <code>matt@tribble-mbp.local</code>. Alternatively you can instead use the computer name as <code>localhost</code> making the email<code>matt@localhost</code>.</p>

<p>Once you have the email set to your local machine you can use the built in <strong>mail</strong> program in MacOS.</p>

<h2>Using command line mail</h2>

<p>To use mail you need to fire up the Terminal.app (Finder > Go > Utilities > Terminal) and type <code>mail</code>. Most of the time you will be presented with a very boring response similar to this:</p>

<p><pre class="brush: plain;">No mail for matt</pre></p>

<p>If you do have mail you will instead see an interactive prompt similar to this:</p>

<p><pre class="brush: plain;">&gt;N  1 matt@tribble-mbp.loc  Tue Jun 16 10:40  14/493   &quot;Test&quot;
? </pre></p>

<p>This is your mailbox, and in my case shows I have 1 new message from matt@tribble-mbp.loc(al) which was sent on Tuesday June 16 at 10:20. The subject of the message is &#8220;Test&#8221;. This is helpful but how do I view the message?</p>

<h2>Handy mail commands</h2>

<table>
<tr>
<th>Command</th>
<th>Purpose</th>
</tr>
<tr>
<td><code>1</code> (or any other number)</td>
<td>Display the message with the ID equal to 1</td>
</tr>
<tr>
<td><code>help</code></td>
<td>Display the help screen</td>
</tr>
<tr>
<td>h</td>
<td>List the headers of the emails </td>
</tr>
<tr>
<td>d1</td>
<td>Delete message 1 (warning this is instant, there is no confirmation step)</td>
</tr>
<tr>
<td>d1-10</td>
<td>Delete messages 1 through 10</td>
</tr>
<tr>
<td>q</td>
<td>Quit mail</td>
</tr>
</table>

<h2>Sending mail</h2>

<p>The easiest way to send mail is to use the website you are developing but, should you wish to, you can use the command line tool. The best way to understand this is an example. We&#8217;re going to send an email to ourselves with the subject &#8220;Test&#8221; and the message &#8220;What&#8217;s up doc?&#8221;. To do this fire up Terminal.app and do the following:</p>

<ul>
<li>Enter <code>mail matt@tribble-mbp.local</code> replacing <code>matt@tribble-mbp.local</code> with the correct address for you.</li>
<li>You will be prompted for the <code>Subject:</code> so enter <code>Test</code> and press enter/return.</li>
<li>It now looks like nothing is happening but in reality mail is waiting for you to enter the body of the message. On the line that has just started type <code>What's up doc?</code> but do not press enter.</li>
<li>To finish the message we have to &#8216;interrupt&#8217; the program. We do this by holding down <code>ctrl</code> on the keyboard and pressing &#8220; (sometimes you need to press it a couple of times).</li>
<li>You should find the letters <code>EOT</code> appear and the program exits. If not, release any keys you have and try pressing <code>ctrl</code> and <code>d</code> again until it does.</li>
</ul>

<p>When all is done the screen should look similar to this:</p>

<p><pre class="brush: plain;">mail matt@tribble-mbp.local
Subject: Test
What's up doc?EOT</pre></p>

<p>Great! you&#8217;ve sent your first mail. Lets take a look at it by entering <code>mail</code> in the terminal. You should find something similar to this:</p>

<p><pre class="brush: plain;">&gt;N  1 matt@tribble-mbp.loc  Tue Jun 16 10:44  14/486   &quot;Test&quot;
? 1
Message 1:
From matt@tribble-mbp.local  Tue Jun 16 10:44:10 2009
X-Original-To: matt@tribble-mbp.local
Delivered-To: matt@tribble-mbp.local
To: matt@tribble-mbp.local
Subject: Test
Date: Tue, 16 Jun 2009 10:44:10 +0100 (BST)
From: matt@tribble-mbp.local (Matt Harris)
What's up doc?</pre></p>

<p>To delete the message type <code>d1</code>, replacing the 1 with the correct ID of the message.</p>

<h2>Sending attachments</h2>

<p>Sending attachments is again something you would probably want to do using your web application however it is quite straight forward. The method here does have it&#8217;s problems with encoding but works out of the box &ndash; as this is only for development and on the local machine it&#8217;s something I&#8217;m happy living with. To send an attachment use the following command:</p>

<p><pre class="brush: plain;">uuencode /path/to/file.jpg filename-for-recipient.jpg | mail matt@tribble-mbp.local</pre></p>

<p>This will send a single message with the @file.jpg@ attached to the message. Helpful but what about sending some text with the message as well? Well, this is achieved using <code>echo</code> and the <code>|</code> technique, like this:</p>

<p><pre class="brush: plain;">(echo &quot;My message test&quot;; uuencode /path/to/file.jpg filename-for-recipient.jpg) | mail matt@localhost</pre></p>

<p>Alternatively you can send a text file as message text using the <code>cat</code> command like this:</p>

<p><pre class="brush: plain;">(cat mytextfile.txt; uuencode /path/to/file.jpg filename-for-recipient.jpg) | mail matt@localhost</pre></p>

<h2>Summary</h2>

<p>Hopefully this has been useful for you. I found it partifularly helpful for debugging this. Knowing how mail works also means you can setup automated mailings from your MacOS to yourself, such as log files or alerts.</p>

<p>When you start using mail a lot, managing messages in the command line can become quite laboured so in my next post I&#8217;ll show you how to read the command line mail using Thunderbird.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F06%2Fusing-local-mail-varmailuser%2F&amp;seed_title=Using+local+mail+%28%2Fvar%2Fmail%2Fuser%29/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Websites on Google Android</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F06%2Ftesting-websites-on-google-android%2F&amp;seed_title=Testing+Websites+on+Google+Android</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F06%2Ftesting-websites-on-google-android%2F&amp;seed_title=Testing+Websites+on+Google+Android#comments</comments>
		<pubDate>Tue, 02 Jun 2009 22:14:36 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[browsertesting]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://themattharris.com/?p=303</guid>
		<description><![CDATA[The other day I was developing a site for a client who wanted to be sure their new site would work on the Android platform. I don&#8217;t own a phone which runs Android so I started looking around for an emulator instead. If you do the same you&#8217;ll quickly find the Android Development website which [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was developing a site for a client who wanted to be sure their new site would work on the Android platform. I don&#8217;t own a phone which runs Android so I started looking around for an emulator instead. If you do the same you&#8217;ll quickly find the <a href="http://developer.android.com/index.html" rel="external">Android Development</a> website which holds a wealth of Android development information aswell as the <acronym title="Software Development Kit">SDK</acronym>. This is helpful but I found it wasn&#8217;t clear whether this would let me test websites or not. For this reason I&#8217;ve put together this quick how-to on getting the Android emulator running on your computer.<span id="more-303"></span></p>

<h2>What you will need</h2>

<ul>
<li>The latest <a href="http://developer.android.com/sdk/" rel="external">Android SDK</a></li>
<li>At least version 1.5 of the <a href="http://java.sun.com/javase/downloads/index.jsp" rel="external">Java Developer Kit</a>. (type @java -version@ into your terminal or command prompt to find out the version you have).</li>
<li>About 10 minutes of time</li>
</ul>

<h2>Setting Up</h2>

<ol>
<li>Follow the instructions on the Android <a href="http://developer.android.com/sdk/1.5_r2/installing.html" rel="external">SDK installation page</a> making sure you follow the steps for adding the tools directory to your path. In my case I put the SDK into <code>~/Code/Android</code> (where <code>~/</code> is my home directory).</li>
<li>Restart your command prompt or terminal and type <code>android</code>. You should be presented with the android help information. If not check you set the path correctly.</li>
</ol>

<h2>Target Platforms and Android Virtual Devices (AVDs)</h2>

<p>It is possible to create emulators (AVDs) for each version (or target) of Android. To do this we need to check which hardware targets are available and what their target ID is. If you type <code>android list targets</code> into your terminal you will be presented with something similar to the code below.
<pre class="brush: plain;">Available Android targets:
id: 1
     Name: Android 1.1
     Type: Platform
     API level: 2
     Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 2
     Name: Android 1.5
     Type: Platform
     API level: 3
     Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P
id: 3
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Description: Android + Google APIs
     Based on Android 1.5 (API level 3)
     Libraries:
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: HVGA (default), HVGA-L, QVGA-P, HVGA-P, QVGA-L
</pre></p>

<p>From this information we can see the SDK supports Android 1.1 and 1.5 and their target IDs are 1 and 2 respectively. Knowing this information we can now create our Android Virtual Device. To create an AVD for Android 1.1 (target ID 1) with the name <strong>android1.1</strong> we type:</p>

<p><pre class="brush: plain;">android create avd -n android1.1 -t 1</pre></p>

<p>Similarly for Android 1.5 we type:</p>

<p><pre class="brush: plain;">android create avd -n android1.5 -t 2</pre></p>

<p>A few things to know about AVDs.
* When creating AVDs you can use any name you like. I choose <strong>android1.1</strong> and <strong>android1.5</strong> as they were easier to remember.
* When prompted about hardware settings just press <code>enter</code> as there should be no need to customise the hardware when testing websites.
* AVDs are created in a hidden folder in the root of your home directory. On Linux and MacOS this is <code>~/.android/avd</code>.
* You can find out what AVDs you have by typing <code>android list avd</code> in the terminal.</p>

<h2>Running the Emulator</h2>

<p>Having created the AVDs we can now run the emulator by typing <code>emulator -avd avdname</code>. This command is the one you will need to use from now on if you want to test websites in Android. For example, if we want to emulate Android 1.1 we would type:</p>

<p><pre class="brush: plain;">emulator -avd android1.1</pre></p>

<p>The first time you run the emulator you will be asked if you are happy for Emulator to send usage statistics to Google.
<img src="/content/uploads/2010/01/android-firstrun-300x209.png" alt="The Android SDK Permission to send usage statistics prompt" title="Android First Run" width="300" height="209" class="align-left size-medium wp-image-309" /></p>

<p>It can take about 10-30 seconds for the Android Emulator to boot up. During this time you will see the Android boot screen.
<img src="/content/uploads/2010/01/android-loading-300x250.png" alt="Android Emulator Boot Screen" title="Android Loading" width="300" height="250" class="size-medium wp-image-311" /> <img src="/content/uploads/2010/01/android-loaded-300x250.png" alt="Android Emulator Home Screen" title="Android Home Screen" width="300" height="250" class="size-medium wp-image-310" /></p>

<p>That&#8217;s it! To test your websites just load the Browser from the home screen. To enter a URL click Menu and then select <strong>Go</strong> or <strong>Go to URL</strong> depending on the version of Android you are running.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F06%2Ftesting-websites-on-google-android%2F&amp;seed_title=Testing+Websites+on+Google+Android/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Resetting Permissions</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F05%2Fresetting-permissions%2F&amp;seed_title=Resetting+Permissions</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F05%2Fresetting-permissions%2F&amp;seed_title=Resetting+Permissions#comments</comments>
		<pubDate>Fri, 08 May 2009 16:11:20 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[reset]]></category>

		<guid isPermaLink="false">http://themattharris.com/?p=286</guid>
		<description><![CDATA[Recently I found myself needing to reset permissions on a website whose files and folders had been changed to 777. For those who are not familiar with permissions this means all the files and folders are readable but more importantly writeable but anyone. It also makes files executable, or runnable on the server. This could [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I found myself needing to reset permissions on a website whose files and folders had been changed to 777. For those who are not familiar with permissions this means all the files and folders are readable but more importantly writeable but anyone. It also makes files executable, or runnable on the server. This could be something you want for upload folders or files you want to be able to edit through a web interface, but not for a whole site. Whatever the reason if the permissions on a folder are messed up this little snippet will reset the permission to the common ones set in a web folder.</p>

<p><pre class="brush: plain;">chmod -R 0755 directory
cd directory
find ./ -type f  -exec chmod 644 {} \;</pre></p>

<p>The first command resets all files and folders to 755, allowing everyone to read and execute (or traverse for directories) and the owner to modify. The third command then resets just files to 644 which drops the allowed to execute flag, turning files from programs into files again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F05%2Fresetting-permissions%2F&amp;seed_title=Resetting+Permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>themattharris.com gets a long overdue update</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F04%2Fthemattharriscom-gets-a-long-overdue-update%2F&amp;seed_title=themattharris.com+gets+a+long+overdue+update</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F04%2Fthemattharriscom-gets-a-long-overdue-update%2F&amp;seed_title=themattharris.com+gets+a+long+overdue+update#comments</comments>
		<pubDate>Mon, 20 Apr 2009 20:36:58 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[redesign]]></category>

		<guid isPermaLink="false">http://themattharris.com/?p=272</guid>
		<description><![CDATA[So it&#8217;s long overdue and really should have happened sooner but finally I&#8217;ve got around to updating my site. The reasons for this will become clear later this week but for now I&#8217;m just happy it&#8217;s live. The whole thing is marked up in HTML 5 and uses the new structural elements mentioned in the [...]]]></description>
			<content:encoded><![CDATA[<p>So it&#8217;s long overdue and really should have happened sooner but finally I&#8217;ve got around to updating my site. The reasons for this will become clear later this week but for now I&#8217;m just happy it&#8217;s live. The whole thing is marked up in HTML 5 and uses the new structural elements mentioned in the <a href="http://dev.w3.org/html5/spec/Overview.html#sections">spec</a>.  I&#8217;ll write up how I approached making the site work in all major browsers, along with the links to the sites that helped and my source code. I&#8217;ve got a few posts queued up ready to publish including the long awaited part 4 of my git sequence.</p>

<p>I know previous parts of the site like the Flickr and Lifestream integration are missing &#8211; it&#8217;s ok, they will come back! &#8211; I&#8217;m just fixing up some of the new library I&#8217;m writing to manage them.</p>

<p>Anyway, let me know what you think of the site and more importantly if you have any problems viewing it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F04%2Fthemattharriscom-gets-a-long-overdue-update%2F&amp;seed_title=themattharris.com+gets+a+long+overdue+update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: MacOS, Apache and Virtual Hosts</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F02%2Fhowto-macos-apache-and-virtual-hosts%2F&amp;seed_title=How+To%3A+MacOS%2C+Apache+and+Virtual+Hosts</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F02%2Fhowto-macos-apache-and-virtual-hosts%2F&amp;seed_title=How+To%3A+MacOS%2C+Apache+and+Virtual+Hosts#comments</comments>
		<pubDate>Wed, 25 Feb 2009 15:49:46 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macos]]></category>
		<category><![CDATA[vhost]]></category>
		<category><![CDATA[virtual host]]></category>
		<category><![CDATA[vitualhost]]></category>

		<guid isPermaLink="false">http://themattharris.com/?p=209</guid>
		<description><![CDATA[When developing a website I&#8217;m sure many of you are checking the pages work and look the way they should.  If you&#8217;re only working on one site this isn&#8217;t too much of problem as you can place the site into your ~/Sites folder, turn on web sharing in Preferences and run the site from [...]]]></description>
			<content:encoded><![CDATA[<p>When developing a website I&#8217;m sure many of you are checking the pages work and look the way they should.  If you&#8217;re only working on one site this isn&#8217;t too much of problem as you can place the site into your <code>~/Sites</code> folder, turn on web sharing in Preferences and run the site from your local machine.  If you&#8217;re like me though, and work on multiple sites at once, this isn&#8217;t a good idea.  It&#8217;s an inefficient workflow and there is a hugh risk of data loss resulting from the need to move and copy files in and out of the folder.</p>

<p>A better way, which many of my professional colleagues and friends do, is to use MAMP or headdress.  These two products provide a graphical interface to allow you to set up hosts on your computer and point the host to a folder on your computer.  This is great except when you want to start developing with multiple languages, or wish to test SSL or external libraries.  It also costs money as the virtual hosts ability is part of MAMP Pro, not the free MAMP edition.</p>

<p>So, although each of these products has their own strengths, is there a way to do what they do without using them.  Luckily enough there is, and i&#8217;ll talk you through it now.</p>

<h2>Assumptions</h2>

<p>First off, i&#8217;m going to make some assumptions:</p>

<ol>
<li>You&#8217;re using a Mac</li>
<li>You&#8217;re using Mac OS Leopard version 10.5.2 or higher</li>
<li>You know what the terminal is and</li>
<li>You know what the file paths are in MacOS</li>
<li>You&#8217;ve turned MAMP off and reset anything setup by Headdress</li>
</ol>

<h2>What you&#8217;ll need</h2>

<ul>
<li>About 30 minutes of time (although you can do this in 2 minutes if you know your way around the shell)</li>
<li>4 files

<ol>
<li>/etc/hosts</li>
<li>/etc/apache2/extra/httpd-vhosts.conf</li>
<li>/etc/apache2/users/USERNAME.conf (where username is the short username for your logon to your computer)</li>
<li>/etc/apache2/httpd.conf</li>
</ol></li>
<li>A text editor. I use TextMate which means I can go into the terminal and type <code>mate /path/to/file</code> to edit the files. I&#8217;m going to use this notation throughout so remember to substitute <code>mate</code> with your favoured text editor.</li>
</ul>

<h2>Step 1: Allowing Overrides and Options</h2>

<p>Open terminal and navigate to /etc/apache2/users and then list the contents of the folder.</p>

<p><pre class="brush: plain;">cd /etc/apache2/users
ls -l</pre></p>

<p>You will see a <code>.conf</code> file for each account on your computer. The one you want is the one which matches your short username for MacOS. In my case it is <code>matt.conf</code></p>

<p>Edit this file in your favourite editor</p>

<p><pre class="brush: plain;">mate /etc/apache2/users/matt.conf</pre></p>

<p>By default this file will look like this:</p>

<p><pre class="brush: plain;">&lt;Directory &quot;/Users/matt/Sites/&quot;&gt;
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;</pre></p>

<p>You need to change the <code>Options</code> and <code>AllowOverride</code> lines to <code>All</code>, so the file should now look like:</p>

<p><pre class="brush: plain;">&lt;Directory &quot;/Users/matt/Sites/&quot;&gt;
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
&lt;/Directory&gt;</pre></p>

<p>Save the file.</p>

<h2>Step 2: Configuring Apache</h2>

<p>Open <code>/etc/apache2/httpd.conf</code> and make the following changes (the line numbers are correct for a fresh install but could be slightly different on your machine. The content remains the same though):</p>

<table>
<tr>
<th>Line</th>
<th>Before</th>
<th>After</th>
<th>Change</th>
</tr>
<tr>
<td>114</td>
<td><code>#LoadModule php5_module libexec/apache2/libphp5.so</code></td>
<td><code>LoadModule php5_module libexec/apache2/libphp5.so</code></td>
<td>ensure the # is not present</td>
</tr>
<tr>
<td>461</td>
<td><code>#Include /private/etc/apache2/ extra/httpd-vhosts.conf</code></td>
<td><code>Include /private/etc/apache2/ extra/httpd-vhosts.conf</code></td>
<td>ensure the # is not present</td>
</tr>
</table>

<p>Save the file.</p>

<h2>Step 3: Configuring your virtual hosts</h2>

<p>Open <code>/etc/apache2/extra/httpd-vhosts.conf</code>. Everything after line 26 is an example of what needs to go in the file and can safely be removed.  Alternatively you can comment the lines out with <code>#</code> if you prefer.</p>

<p>Here&#8217;s an example of what to put here, assuming:</p>

<ul>
<li>My website files are kept in <code>/Users/matt/Sites/themattharris.com</code> (remember this is case sensitive)</li>
<li>I want to test the server with the DNS name <code>www.themattharris.com</code></li>
</ul>

<p>In this case I would put the following entry into the <code>httpd-vhosts.conf</code> file:</p>

<p><pre class="brush: plain;">&lt;VirtualHost *:80&gt;
   DocumentRoot &quot;/Users/matt/Sites/themattharris.com&quot;
   ServerName www.themattharris.com
&lt;/VirtualHost *:80&gt;
</pre></p>

<h2>Step 4: Make the computer think the domain is on the localhost</h2>

<p>Open <code>/etc/hosts</code>. You&#8217;ll see something like:</p>

<p><pre class="brush: plain;">&#35;#
&#35; Host Database
&#35;
&#35; localhost is used to configure the loopback interface
&#35; when the system is booting.  Do not change this entry.
&#35;#
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0 localhost</pre></p>

<p><strong>DO NOT</strong> change any of those lines, they&#8217;re critical to the workings of your computer. What you want to do is instead add lines to the end of the file, like the following for each of your virtual hosts:</p>

<p><pre class="brush: plain;">127.0.0.1      www.themattharris.com</pre></p>

<ul>
<li>127.0.0.1 means my computer even when it&#8217;s not connected a network</li>
<li>The domain name should match the one you used for the ServerName (or ServerAlias if you used that) in <code>/etc/apache2/extra/httpd-vhosts.conf</code></li>
</ul>

<h2>h3. Step 5: Restart Apache</h2>

<p>This can be done through System Preferences by turning Web Sharing off then on again.  Alternatively, a quicker way is to use terminal and type:</p>

<p><pre class="brush: plain;">sudo apachectl graceful</pre></p>

<p>and enter you password when prompted.</p>

<p>All being well if you now point to the domain you setup in hosts you will see the web pages on your local machine. To add more virtual hosts just repeat step 3, 4 and 5.</p>

<h2>Turning a virtual host off</h2>

<p>When you want to visit the live site again you don&#8217;t need to change anything apart from edit <code>/etc/hosts</code> and place a <code>#</code> at the start of the line for the domain you want to turn off.</p>

<p><pre class="brush: plain;">#127.0.0.1      www.themattharris.com</pre></p>

<h2>Troubleshooting</h2>

<p>If you are having problems and the domains are not working open the apache error log (<code>/private/var/log/apache2/error_log</code>) and see what it says.  Quite often you&#8217;ll find you&#8217;ve got the path in the wrong case and Apache couldn&#8217;t find the file.</p>

<p>Let me know how you do with this. In a couple of days I&#8217;ll show how to enable SSL on the virtual hosts and also how to compile the GD graphics library to work with MacOS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2009%2F02%2Fhowto-macos-apache-and-virtual-hosts%2F&amp;seed_title=How+To%3A+MacOS%2C+Apache+and+Virtual+Hosts/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Breast Cancer Awareness Month</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F10%2Fbreast-cancer-awareness-month%2F&amp;seed_title=Breast+Cancer+Awareness+Month</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F10%2Fbreast-cancer-awareness-month%2F&amp;seed_title=Breast+Cancer+Awareness+Month#comments</comments>
		<pubDate>Mon, 20 Oct 2008 21:43:41 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[breast cancer]]></category>
		<category><![CDATA[pink]]></category>

		<guid isPermaLink="false">http://www.themattharris.com/?p=98</guid>
		<description><![CDATA[

October is Breast Cancer Awareness Month and so, to help raise awareness of breast cancer, Cindy drew me a pink version of my site which I have coded up for you all to see.

Now I&#8217;m not the only one doing this, lots of sites have gone Pink for October and you can find out more [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/content/uploads/2010/01/screenshot.png" alt="themattharris.com | Pink for October" width="300" height="283" class="alignleft size-full wp-image-192" /></p>

<p>October is Breast Cancer Awareness Month and so, to help raise awareness of breast cancer, <a href="http://www.cindyli.com" rel="sweetheart met colleague">Cindy</a> drew me a pink version of my site which I have coded up for you all to see.<span id="more-98"></span></p>

<p>Now I&#8217;m not the only one doing this, lots of sites have gone <a href="http://pinkforoctober.org/">Pink for October</a> and you can find out more on that site.  The <acronym title="British Broadcasting Corporation">BBC</acronym> also has a useful <a href="http://www.bbc.co.uk/health/womens_health/issues_breastcancer1.shtml">health page</a> if you are interested in learning more about Breast Cancer, the treatments, and also about early signs.</p>

<p>For those of you viewing this post after October 31st 2008 you can see how the site looked during the month in the screenshot on the left.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F10%2Fbreast-cancer-awareness-month%2F&amp;seed_title=Breast+Cancer+Awareness+Month/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding timezones into Upcoming Feeds</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F09%2Fadding-timezone-into-upcoming-feeds%2F&amp;seed_title=Adding+timezones+into+Upcoming+Feeds</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F09%2Fadding-timezone-into-upcoming-feeds%2F&amp;seed_title=Adding+timezones+into+Upcoming+Feeds#comments</comments>
		<pubDate>Tue, 09 Sep 2008 22:50:08 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[Presentations]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[barcampbrighton]]></category>
		<category><![CDATA[barcampbrighton3]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[timezone]]></category>
		<category><![CDATA[upcoming]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.themattharris.com/?p=106</guid>
		<description><![CDATA[This is the presentation I gave at Barcamp Brighton 3 on 6th September 2008.  It gives an overview of an approach I have taken to insert timezones into my watchlist REST feed generated by Upcoming.  The pipe described here is version 1 which adds a new node into the REST response.  Whilst [...]]]></description>
			<content:encoded><![CDATA[<p>This is the presentation I gave at <a href="http://barcampbrighton.org/">Barcamp Brighton 3</a> on 6th September 2008.  It gives an overview of an approach I have taken to insert timezones into my watchlist REST feed generated by Upcoming.  The pipe described here is version 1 which adds a new node into the REST response.  Whilst not ideal this is the current solution.</p>

<p>You can view the presentation &#8220;Adding a Timezone into your Upcoming Feed&#8221; on <a href="http://docs.google.com/Presentation?id=dx9zpjc_55gzvzfkg4">Google Docs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F09%2Fadding-timezone-into-upcoming-feeds%2F&amp;seed_title=Adding+timezones+into+Upcoming+Feeds/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up your Git installation to use a remote repository (git clone)</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F08%2Fsetting-up-your-git-installation-to-use-a-remote-repository-git-clone%2F&amp;seed_title=Setting+up+your+Git+installation+to+use+a+remote+repository+%28git+clone%29</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F08%2Fsetting-up-your-git-installation-to-use-a-remote-repository-git-clone%2F&amp;seed_title=Setting+up+your+Git+installation+to+use+a+remote+repository+%28git+clone%29#comments</comments>
		<pubDate>Thu, 28 Aug 2008 01:40:41 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[SysAdmin]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[unfuddle]]></category>

		<guid isPermaLink="false">http://www.themattharris.com/?p=88</guid>
		<description><![CDATA[This is part 3 of a 4 part series of setting up your systems to use Git.

So you&#8217;ve installed Git on your remote server and now want to be able to keep connect to a remote Git repository.  This post will go through setting up a connection to two popular repository hosting providers, Unfuddle [...]]]></description>
			<content:encoded><![CDATA[<p>This is part 3 of a 4 part series of setting up your systems to use Git.</p>

<p>So you&#8217;ve installed Git on your remote server and now want to be able to keep connect to a remote Git repository.  This post will go through setting up a connection to two popular repository hosting providers, <a href="http://www.unfuddle.com">Unfuddle</a> and <a href="http://www.github.com">Github</a>. I should stress these sites provide instructions on how to connect to their repositories and so what I talk about here is already on these sites; I just wanted to have a complete set of instructions available in one place.<span id="more-88"></span></p>

<h2>What you will need</h2>

<ul>
<li>SSH root access to your server (MediaTemple offer this though the <a href="http://ac.mediatemple.net">Account Center</a></li>
<li>An account on Unfuddle or Github</li>
<li>An SSH Keypair setup on your server (if you&#8217;ve not done this yet see <a href="/2008/08/06/generating-an-ssh-keypair/">Generating an SSH Keypair</a></li>
<li>About 15 minutes of time</li>
</ul>

<h2>Find out your SSH Key</h2>

<p>Remote repositories use SSH Tunnels to transmit data between client and host.  For this to work we need to register the SSH Key on our server with the remote repository. To find out what your SSH Key is you need to:</p>

<ol>
<li>Log into your server using SSH. Usually this is <code>ssh root@your-domain.com</code></li>
<li>Print the key to the terminal by entering the command : <code>cat ~/.ssh/id_rsa.pub</code></li>
<li>Copy everything that was just output to the screen to a blank document or your clipboard. It will be something like <code>ssh-rsa == root@</code></li>
</ol>

<h2>Registering our key with the remote repository</h2>

<p>Now we have our SSH key we need to register it with our account on the remote repository. For Github this is on your <a href="https://github.com/account">account page</a> under &#8220;SSH Public Keys&#8221;. On Unfuddle it&#8217;s on the &#8220;Personal Settings&#8221; page under &#8220;Public Keys&#8221;.</p>

<ol>
<li>On Github choose to &#8220;add another public key&#8221;, whilst on Unfuddle choose &#8220;New Public Key&#8230;&#8221;</li>
<li>You&#8217;ll be asked for a title and a value. Enter a name in the title box which will identify this key clearly, for example &#8220;root on example.com&#8221;. In the value box paste the key pair you copied from the terminal window earlier.</li>
</ol>

<p>These services now know who we are and we can authenticate with them. The next stage is to connect to the remote repositories.</p>

<h2>Connecting to the remote repositories</h2>

<ol>
<li>First thing you&#8217;ll want to do is find the Git Clone address. On Unfuddle this is displayed under the name of the repository on the Repositories page.  On Github the address is called the Public Clone URL and can be found on the Source page for the repository. It will look something like <code>git@something.unfuddle.com:something/project.git</code> or <code>git@github.com/username/project.git</code></li>
<li>SSH into your server if your not in it any longer.</li>
<li>Navigate into the folder which will contain your clone of the Git repository.</li>
<li>Git cannot be cloned as a folder which already exists. If you want to clone the repository to a folder called &#8220;apples&#8221; you need to make sure the folder &#8220;apples&#8221; doesn&#8217;t exist already. In this case i&#8217;m going to clone my git repository into the folder <code>httpdocs</code> by using the command <code>git clone  httpdocs</code></li>
<li>If this is the first time you&#8217;ve connect to the repository you&#8217;ll likely be asked to accept the RSA key fingerprint. Check the host name and IP that&#8217;s displayed and if your happy answer <code>yes</code></li>
<li>You&#8217;ll now be asked for the passphrase to your key. This is the phrase you entered when creating your SSH key pair before. This isn&#8217;t your SSH login password (unless you made them the same &#8211; which you really shouldn&#8217;t).</li>
<li>If you get errors here such as <strong>fatal: The remote end hung up unexpectedly</strong> make sure your password is correct and that you&#8217;ve registered your SSH key with your provider</li>
</ol>

<p>You&#8217;ve now got a clone of the remote repository on your server. Now check the permissions are correct for your requirements.  In my case I&#8217;ve cloned the repository into my web folder so I need to reset the permissions to those of my web account.</p>

<p>Now, whenever you want to update the copy of the code on your server just run <code>git pull</code></p>

<p>In part 4 of this 4 part series I&#8217;ll talk about how I use Git to keep my production servers and easily publish updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F08%2Fsetting-up-your-git-installation-to-use-a-remote-repository-git-clone%2F&amp;seed_title=Setting+up+your+Git+installation+to+use+a+remote+repository+%28git+clone%29/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Locally hosted websites and virtual machines</title>
		<link>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F08%2Flocally-hosted-websites-and-virtual-machines%2F&amp;seed_title=Locally+hosted+websites+and+virtual+machines</link>
		<comments>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F08%2Flocally-hosted-websites-and-virtual-machines%2F&amp;seed_title=Locally+hosted+websites+and+virtual+machines#comments</comments>
		<pubDate>Sat, 09 Aug 2008 01:08:11 +0000</pubDate>
		<dc:creator>themattharris</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[browsertesting]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[parallels]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.themattharris.com/?p=51</guid>
		<description><![CDATA[So here&#8217;s the situation. You&#8217;ve got a development copy of a website on your local Macbook and you&#8217;ve been making some changes to it. Everything looks great but you want to make sure you haven&#8217;t made changes that stop the site rendering the way you expect in Internet Explorer or Firefox 2.  Usually you&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<p>So here&#8217;s the situation. You&#8217;ve got a development copy of a website on your local Macbook and you&#8217;ve been making some changes to it. Everything looks great but you want to make sure you haven&#8217;t made changes that stop the site rendering the way you expect in Internet Explorer or Firefox 2.  Usually you&#8217;d make use of your corporate network computers to test the site but your working remotely so don&#8217;t have that luxury. You do, however, have a couple of virtual machines running Windows XP and different versions of browsers.  The question is, how do you test the changes without committing them to the live site?<span id="more-51"></span></p>

<p>The answer is remarkably simple and allows you to test any site hosted on your local machine with browsers installed on your virtual machines. In all of this I am assuming your running Mac OS X and Windows XP in the virtual machine.  That being said, as long as your know your hosts IP address and the virtual machine is running Windows 95 upwards this will work. By host I mean the machine which you run VMWare or Parallels on.</p>

<h2>What you need</h2>

<ul>
<li>A virtual machine application such as <a href="http://www.vmware.com/products/desktop_virtualization.html">VMWare</a> or <a href="http://www.parallels.com/en/desktop/">Parallels</a></li>
<li>A website hosted on your local machine</li>
</ul>

<h2>What to do</h2>

<p>With your virtual machine turned off, edit it&#8217;s settings to ensure it is running the Network card in &#8220;Bridged&#8221; mode.  What this does is allow your virtual machine to appear on your network as if it was another computer, rather that the default NAT mode that hides the virtual machine behind the hosts IP address.</p>

<p>Next start up your virtual machine and whilst it&#8217;s loading, make a note of the hosts IP address. You can find your IP address in the network preferences or through the command <code>ipconfig</code> (Windows) or <code>ifconfig</code> (Linux and Mac).</p>

<p>With the virtual machine now loaded go to Start > Run and type <code>notepad "c:\windows\system32\drivers\etc\hosts"</code>. This will load up the file Windows uses to alias IP addresses to host names.</p>

<p><img src="/content/uploads/2010/01/hosts.jpg" alt="The default Windows hosts file" width="661" height="419" class="alignnone size-full wp-image-202" /></p>

<p>The file is very well explained but in a nutshell, you put the IP address of the host at the beginning of the line, and the domain name that should point to it. So, lets assume my host IP is 10.0.1.97 and the domain I am developing is www.themattharris.com. In the hosts file I would enter a new line as</p>

<p><pre class="brush: plain;">10.0.1.97       www.themattharris.com</pre></p>

<p>Now lets assume i&#8217;m also developing another domain on the host called www.tokofu.com. All I need to do is add another line to the hosts file <pre class="brush: plain;">10.0.1.97       www.tokofu.com</pre></p>

<p><img src="/content/uploads/2010/01/filledin.jpg" alt="Hosts file filled" width="661" height="419" class="alignnone size-full wp-image-201" /></p>

<p>Save the file and test in your virtual machine. The domains you entered into the Windows hosts file will have caused your web browser to request the site from your host and not the Internet.</p>

<p>We can also validate this by running two commands in the Windows Command Prompt. If we run <code>nslookup</code> the computer will lookup the domain name using a DNS server.  If we run the command <code>ping</code> Windows instead uses the address it knows from the hosts file. You can see this by loading a command prompt (Start &gt; Run and type <code>cmd</code> ) and entering <code>nslookup your-domain.com</code> and <code>ping your-domain.com</code></p>

<p><img src="/content/uploads/2010/01/addresscompare.jpg" alt="addresscompare" width="674" height="344" class="alignnone size-full wp-image-200" /></p>

<p>To restore the default behaviour you edit the &#8220;c:\windows\system32\drivers\etc\hosts&#8221; file and either delete the lines you entered, or start the line with a &#35; (this marks the line as a comment).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.themattharris.com/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fthemattharris.com%2F2008%2F08%2Flocally-hosted-websites-and-virtual-machines%2F&amp;seed_title=Locally+hosted+websites+and+virtual+machines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
