<?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>jesperrasmussen.com &#187; Development</title>
	<atom:link href="http://jesperrasmussen.com/category/development/feed" rel="self" type="application/rss+xml" />
	<link>http://jesperrasmussen.com</link>
	<description>confessions of yet another Mac-geek</description>
	<lastBuildDate>Wed, 07 Mar 2012 19:36:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Coding on the go &#8211; Setting up local Apache</title>
		<link>http://jesperrasmussen.com/coding-on-the-go-setting-up-local-apache</link>
		<comments>http://jesperrasmussen.com/coding-on-the-go-setting-up-local-apache#comments</comments>
		<pubDate>Thu, 27 Aug 2009 16:13:11 +0000</pubDate>
		<dc:creator>Jesper</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://jesperrasmussen.com/?p=43</guid>
		<description><![CDATA[As one might imagine, I&#8217;ve setup Apache with PHP support quite some times over the last years. A thing I&#8217;ve already enjoyed, is having a local development environment installed on my laptop, and having my development environment with me, everywhere I go. Over the next couple of weeks, I&#8217;ll walk you through setting everything up. [...]]]></description>
			<content:encoded><![CDATA[<p>As one might imagine, I&#8217;ve setup Apache with PHP support quite some times over the last years. A thing I&#8217;ve already enjoyed, is having a local development environment installed on my laptop, and having my development environment with me, everywhere I go. Over the next couple of weeks, I&#8217;ll walk you through setting everything up. We&#8217;ll start out by setting up Apache.<span id="more-43"></span></p>
<h4>Why would I run everything locally ?</h4>
<p>Over the last years, a lot of the development agencies in the PHP world, has found out the joys of having local, individual environments for all developers, and managing larger projects through version control like SVN, CVS or, my new favourite, Git. Most people don&#8217;t have the luxury of having their own dedicated testserver for development, but you really don&#8217;t need one either. If you just have a Mac with OS X, you&#8217;ll have everything you need.</p>
<p>The reasons for having a local environment are quite massive: You&#8217;re able to have a complete replica of a running website, you&#8217;ll be able to develop new features without risking the stability of your public site. You&#8217;ll have full control of every setting in Apache, MySQL and PHP, meaning you&#8217;ll have the opportunity of testing optimizations and database structures properly, without the risk of destroying everything in a production environment.</p>
<h3>Prerequirements</h3>
<p>To complete the setup of Apache &amp; friends, you&#8217;ll need the assistance of Terminal. If you are not comfortable with Terminal, just feel free to copy&#8217;n'paste every command here. Of course, as time passes, and you&#8217;re using your new environment, you&#8217;ll probably notice the advantages of Terminal anyway.</p>
<h3>Setting up Apache</h3>
<p>As Apache 2 is bundled with Leopard, this is very easy. Apache is controlled by enabling Web sharing in System Preferences.</p>
<h4>Setting up webroots</h4>
<p>As you have full control of Apache&#8217;s setup, you could actually put your websites whereever you&#8217;d like. However, as you already have the Sites folder available in your home directory, I&#8217;ll just make use of that. This also ensures, that Time Machine for instance is able to create backups of your sites.</p>
<p>So go ahead and create a directory within Sites for your new site, and try to give it a memorable name (In this example I&#8217;ll use jesperrasmussen.com from now on) .</p>
<p>[shell]sudo mkdir -p ~/Sites/jesperrasmussen.com/htdocs[/shell]</p>
<p>While you&#8217;re at it, add a general directory for Apache&#8217;s logs within Sites, to gather all sites logs within one place, making debugging and log-analyzing a bit easier.</p>
<p>[shell]sudo mkdir ~/Sites/logs[/shell]</p>
<p>Now that that&#8217;s done, you should have a couple of nice directories for the virtualhost and its logfiles, so let&#8217;s move on.</p>
<h4>Setting up a VirtualHost</h4>
<p>In the default setting, Apache will see your Sites folder as one site, as it&#8217;s setup to allow one personal site per user. To make Apache recognize the new virtual hosts, you need to edit the file /private/etc/apache2/users/.conf in your favourite editor (I recommend emacs or nano for Terminal editing).</p>
<p>The file will look somewhat like this when you open it:</p>
<p>[shell]&lt;Directory &quot;/Users/jesper/Sites/&quot;&gt;<br />
 Options Indexes MultiViews<br />
 AllowOverride None<br />
 Order allow,deny<br />
 Allow from all<br />
&lt;/Directory&gt;[/shell]</p>
<p>Now, what we&#8217;ll do, is that we&#8217;ll add the lines for a new virtualhost in the configuration. Furthermore, in my example, there&#8217;s  an added .dev alias to the domain, allowing me to access the local development version of the site by accessing jesperrasmussen.dev, and access the public version (On another server) by accessing jesperrasmussen.com. Anyway, add the following lines, replacing jesperrasmussen.com with whatever your virtual host is called, and save the file.</p>
<p>[shell]NameVirtualHost *:80<br />
DocumentRoot /Users/jesper/Sites/jesperrasmussen.com/htdocs<br />
ServerName jesperrasmussen.com<br />
ServerAlias jesperrasmussen.dev<br />
ErrorLog /Users/jesper/Sites/logs/jesperrasmussen.com-error_log<br />
CustomLog /Users/jesper/Sites/logs/jesperrasmussen.com-access_log common[/shell]</p>
<h4>Restarting Apache</h4>
<p>Inorder to test the new site, we need to reload Apache&#8217;s configuration files. This is done by testing the new config files first.</p>
<p>[shell]sudo apachectl -t[/shell]</p>
<p>If this says &#8220;Syntax OK&#8221;, we should gracefully load the changes into Apache. *)</p>
<p>[shell]sudo apachectl graceful[/shell]</p>
<h4>Accessing your newly created site</h4>
<p>Now, you may think you should be able to access your new site at the domain you&#8217;ve entered. But no, you still need one more thing, changing your hosts-file into handling your domain locally (Or at least, the development version). This is done by editing /etc/hosts (Again, using emacs or nano), like so:</p>
<p>[shell]sudo nano /etc/hosts[/shell]</p>
<p>This should load your hosts-file **), which should look like this:</p>
<p>[shell]127.0.0.1 localhost<br />
255.255.255.255 broadcasthost<br />
::1 localhost<br />
fe80::1%lo0 localhost[/shell]</p>
<p>Now, in the bottom of the file, insert a couple of blank lines to seperate your changes from the default parts, and insert this line:</p>
<p>[shell]127.0.0.1       jesperrasmussen.dev www.jesperrasmussen.dev[/shell]</p>
<p>This will force your machine into believing that your domain is located at localhost, thus making the request at your local Apache.</p>
<p>Now, everything should work, try putting a dummy index.html file in your new htdocs directory, and try loading the site in your browser. Next time I&#8217;ll have a look at enabling PHP and MySQL support on your standard machine.</p>
<h4>Further reading</h4>
<p>It&#8217;s come to my attention that Patrick Gibson has a fine shellscript for handling the VirtualHost part, making this a lot easier.<br />
You might want to <a href="http://patrickgibson.com/utilities/virtualhost/">check that out</a></p>
<hr />
<p>* Gracefully restarting Apache lets Apache apply the configuration more smoothly, by allowing it&#8217;s child processes to keep running with the old configuration, but loading the new configuration for all new processes. This is usually done in production environments, to avoid hard restarting servers, thereby avoiding possible downtime.</p>
<p>** The hosts-file is OS X&#8217;s way of overriding DNS locally. It allows you to force a domain to a specific IP-address rather than the one specified in the domains DNS. This is especially useful for testing a development or staging environment with the correct domainname.</p>
]]></content:encoded>
			<wfw:commentRss>http://jesperrasmussen.com/coding-on-the-go-setting-up-local-apache/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Switching bash with zsh</title>
		<link>http://jesperrasmussen.com/switching-bash-with-zsh</link>
		<comments>http://jesperrasmussen.com/switching-bash-with-zsh#comments</comments>
		<pubDate>Tue, 03 Mar 2009 21:30:25 +0000</pubDate>
		<dc:creator>Jesper</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[shells]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://jesperrasmussen.com/?p=4</guid>
		<description><![CDATA[I&#8217;ve been running OS X since the beginning back in 2001. During that time, the system have gone through a lot of changes, and while some has improved a lot of visual effects, and have a great impact on the way we perceive our tasks at hand, some are more invisible, but also have a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running OS X since the beginning back in 2001. During that time, the system have gone through a lot of changes, and while some has improved a lot of visual effects, and have a great impact on the way we perceive our tasks at hand, some are more invisible, but also have a large effect on the way we work.</p>
<p>I usually spend 20-30% of my day in Terminal, doing administrative tasks, ssh&#8217;ing to the servers I use for development and for my work, watching logs, debugging etc. This might not be typical behaviour for an OS X user (Which is good, as I think Terminal should be an addition for those who wants the power of it, and not a necessity for &#8220;regular&#8221; users) , but I find working directly with Terminal to improve my workflow when it comes to the previously mentioned tasks.</p>
<p>As some Mac-users will know, OS X currently comes with bash as the standard shell. Even though bash is often perceived as one of the best shells available in the Unix-community, quite a lot of other shells exist, all with different features, and approaches to shell-work. A couple of years ago I decided to try out Z Shell, also known as zsh, and I&#8217;ve never regretted this.<span id="more-4"></span></p>
<h3>Why run zsh ?</h3>
<p>To begin with, it&#8217;s not even a big deal switching or trying zsh out. If you are currently using bash, you&#8217;ll feel right at home. Zsh uses a lot of the same shortcuts, has support for most of the features bash uses, and this means the only thing you&#8217;ll actually notice, is how the extra features just make things easier. Some of the key features for zsh are:</p>
<ul>
<li>Nice autocompletion for commands, aliases etc. Zsh allows you to tab through completions if there are multiple possibilities, showing possible completions in a nice grid, browsable even by arrow keys, to make it simple and fast to find exactly the completion you want.</li>
<li>Autocompletion for remote files. If you are using scp to transfer a file to a remote server, zsh will figure out what you are doing, so if you try to autocomplete while typing the remote part, it will try to connect via ssh and actually perform autocompletion on the remote side.</li>
<li>Functions in addition to aliases. It&#8217;s possible to create entire routines as zsh functions with arguments, allowing for complex functionality for running multiple commands in succession easily.</li>
<li>Share history across sessions. When running multiple instances of zsh at the same time, the instances are able to share a common history, rather than being limited to only each its own. One of the most frustrating things to a bash user is typing in a long command, then searching for it again the next day via Ctrl+r, only to find it nowhere in the history.</li>
</ul>
<h3>Ok, so how do I change my shell to zsh ?</h3>
<p>Enabling zsh in OS X Leopard is really easy. Previously, you had to install zsh from <a href="http://www.macports.org/">MacPorts</a>, but in Leopard it&#8217;s part of the base install, and as such is easily accessed. try writing &#8220;zsh&#8221; in your bash, and bang! You&#8217;re running zsh! To set zsh as your default shell in OS X, and make it run every time you start Terminal, load up Terminal&#8217;s settings, and set your default theme to run the command &#8220;zsh&#8221; on startup.</p>
<p><img class="alignnone" title="ZSH Setup on OS X" src="http://jesperrasmussen.com/uploads/zsh-setup.jpg" alt="" width="670" height="535" /></p>
<p>To change it in older OS X versions, you should be able to use the chsh command. But there are <a href="http://osxdaily.com/2007/02/27/how-to-change-from-bash-to-tcsh-shell/">other suggestions</a> as well.</p>
<h3>But, but, it&#8217;s not working like you promised ?</h3>
<p>You&#8217;ll need a .zshrc file to take full advantage of zsh. The .zshrc is zsh&#8217;s configuration file, and will setup most of the features I&#8217;ve mentioned earlier. There&#8217;s a couple of ways of getting hold of a .zshrc. You could google for it, and you&#8217;ll find a bunch of examples. Another way is to take a look at <a href="http://jesperrasmussen.com/uploads/dummy-.zshrc">my sample file</a> . This is not an exact copy of my running .zshrc, but it has a bunch of the most common setups.</p>
<p>To make it work, you have to save the file as .zshrc in your home directory.</p>
<p>Be aware that zsh holds a bunch of more features than I&#8217;ve talked about here, and there&#8217;s much to explore.  Feel free to use my sample file as a starting point, and do change it anyway you&#8217;d like. If you find any other useful features in zsh, please let me know, and I&#8217;ll make some notes about it here.</p>
<h3>Further reading</h3>
<p>If you want to know more about the glorious world of zsh, try checking out the <a href="http://zsh.sourceforge.net/">official zsh website</a>, containing documentation, the manual as well as some pointers to getting started with scripting in zsh.</p>
<p><a href="http://zsh.sourceforge.net/">Zsh homepage</a></p>
<p><a href="http://jesperrasmussen.com/uploads/dummy-.zshrc">My sample .zshrc</a></p>
<p><a href="http://zshwiki.org/">Zsh Wiki</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jesperrasmussen.com/switching-bash-with-zsh/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

