<?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>michaelkrol.com &#187; Apache</title>
	<atom:link href="http://michaelkrol.com/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelkrol.com</link>
	<description>A Web Developer's Blog Highlighting Open Source and OS X</description>
	<lastBuildDate>Mon, 22 Mar 2010 18:01:20 +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>Local Web Development With OS X 10.5 (Leopard)</title>
		<link>http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/</link>
		<comments>http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/#comments</comments>
		<pubDate>Wed, 31 Oct 2007 05:28:50 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/</guid>
		<description><![CDATA[With the release of Leopard last Friday, it appears the bulk of my previous tutorials are now taken care of out of the box. mod_rewrite is enabled by default, and a decent (but not robust) installation of PHP 5.2.4 is ready to go &#8211; it only needs to be uncommented in the Apache configuration file.
The ]]></description>
			<content:encoded><![CDATA[<p>With the release of Leopard last Friday, it appears the bulk of my <a href="http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/" title="mod_rewrite on OS X 10.4">previous</a> <a href="http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/" title="Local Web Development With OS X 10.4">tutorials</a> are now taken care of out of the box. mod_rewrite is enabled by default, and a decent (but not robust) installation of PHP 5.2.4 is ready to go &#8211; it only needs to be uncommented in the Apache configuration file.</p>
<p>The PHP installation is missing some key extensions, like PostgreSQL support and the GD library to name a few. But the majority of commonly used extensions are ready to go. <a href="http://www.entropy.ch/blog/Mac+OS+X/2007/10/30/Leopard-Four-Way-Universal-Binaries.html" title="Marc Liyanage">Marc Liyanage</a> is already on the case and working out the kinks for his own installer including those additions. The only thing missing at this point is <a href="http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg">MySQL support</a> for Leopard. As of this writing, there is no installer available yet.</p>
<p>The rest of this post assumes you are working from a clean install or an &#8220;archive and install&#8221; of 10.5. I&#8217;m not sure what the Apache configuration files may look like if you simply upgraded from 10.4 or 10.3 &#8211; if they are clean this should work just fine.</p>
<p>Open the Apache configuration file (I&#8217;m using <a href="http://macromates.com/" title="TextMate">TextMate</a>, which is where the &#8216;mate&#8217; command comes from):<br />
<code>$ mate /etc/apache2/httpd.conf</code><br />
and scroll to line 114 &#8211; it should look like this:<br />
<code>#LoadModule php5_module        libexec/apache2/libphp5.so</code><br />
Just remove the comment:<br />
<code>LoadModule php5_module        libexec/apache2/libphp5.so</code></p>
<p>To enable Virtual Hosts, uncomment line 461:<br />
<code>Include /private/etc/apache2/extra/httpd-vhosts.conf</code><br />
and add your own directories in your <code>/etc/apache2/users/you.conf</code> file. Similar to the 10.4 configuration, change the first two lines (inside <code>&lt;Directory "/Users...&gt;</code>) like so:<br />
<code>Options All<br />
AllowOverride All</code><br />
and add your Virtual Host directives after that:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites<br />
ServerName localhost<br />
&lt;/VirtualHost&gt;</code></p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites/devsite<br />
ServerName devsite<br />
&lt;/VirtualHost&gt;</code></p>
<p>Restart Apache:<br />
<code>$ sudo apachectl restart</code><br />
and you&#8217;re all set.</p>
<p>The only thing left to do is update your hosts file:<br />
<code>$ mate /etc/hosts</code><br />
and add whatever you used for your ServerName after the other entries:<br />
<code>127.0.0.1  devsite</code></p>
<p>Enjoy!</p>
<p>Now I need to figure out if those <a href="http://weblog.rubyonrails.org/2006/8/7/ruby-on-rails-will-ship-with-os-x-10-5-leopard" title="Ruby on Rails in OS 10.5?">rumors</a> of Ruby on Rails out of the box are true&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Save Time (and code) Using Virtual Hosts For Local OS X Web Development With mod_rewrite</title>
		<link>http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/</link>
		<comments>http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 06:38:33 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development/</guid>
		<description><![CDATA[UPDATE: This tutorial was written for OS X 10.4 and parts of it are no longer necessary with OS X 10.5. See this post for details.
Using a few built-in tools in OS X, I&#8217;ve found a great way to develop sites as Virtual Hosts on Apache. If you are a web developer working on a ]]></description>
			<content:encoded><![CDATA[<p style="border: 1px solid #000000; padding: 3px; background-color: #F7F7F7">UPDATE: This tutorial was written for OS X 10.4 and parts of it are no longer necessary with OS X 10.5. See <a href="http://michaelkrol.com/2007/10/30/local-web-development-with-os-x-105-leopard/" title="Local Web Development With OS X 10.5 Leopard">this post</a> for details.</p>
<p>Using a few built-in tools in OS X, I&#8217;ve found a great way to develop sites as Virtual Hosts on Apache. If you are a web developer working on a Mac and you need to develop sites using root relative paths without adding a <code>base href</code> tag to every page on your site, this tutorial should help tremendously. Here&#8217;s how it works:</p>
<p>First, make sure you&#8217;ve got <a href="http://www.entropy.ch/software/macosx/php/" title="Marc Liyanage's PHP Installer" target="_blank">PHP</a> and <a href="http://dev.mysql.com/downloads/" title="MySQL Download Page" target="_blank">MySQL</a> installed &#8211; those are the only two things you should need to install outside of the stock OS X configuration.</p>
<p>Next, follow <a href="http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/" title="OS X mod_rewrite Fix" target="_blank">this tutorial</a> on enabling mod_rewrite on OS X that I&#8217;ve written previously.</p>
<p>The rest will involve some basic command line use, but it&#8217;s pretty painless. As mentioned in the <a href="http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/" title="OS X mod_rewrite Fix" target="_blank">mod_rewrite tutorial</a>, I highly recommend <a href="http://macromates.com/" title="TextMate" target="_blank">TextMate</a> for editing the configuration files. If you&#8217;re a UNIX purist, there&#8217;s always <a href="http://en.wikipedia.org/wiki/Vi" title="vi text editor" target="_blank">vi</a>.</p>
<p>For this example, create a new folder in your <code>/Users/yourname/Sites</code> folder called <code>devsite</code> and place some files there (a simple html or php file with something to output in a browser will do).</p>
<ol>
<li>Open your <code>httpd.conf</code> file and enable Virtual Hosts:<br />
<code>$ mate /etc/httpd/httpd.conf</code><br />
Around line 1063 (almost at the bottom of the file),  you should find and uncomment this line:<br />
<code>NameVirtualHost *:80</code></li>
<li>Open your users.conf file and add a Virtual Host directive:<br />
<code>$ mate /etc/httpd/users/yourname.conf</code><br />
After the <code>&lt;Directory&gt;...&lt;/Directory&gt;</code> portion, add the following:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites<br />
ServerName localhost<br />
&lt;/VirtualHost&gt;</code></p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/yourname/Sites/devsite<br />
ServerName devsite<br />
&lt;/VirtualHost&gt;</code></p>
<p>Keeping the <code>localhost</code> portion at the top will still allow you to view the root of the server and anything in it&#8217;s directory at <em>http://localhost</em>.</li>
<li>Open your <code>hosts</code> file and add your new site name to bypass DNS:<br />
<code>$ mate  /etc/hosts</code><br />
Make sure these three lines stay at the top:<br />
<code>127.0.0.1                localhost<br />
255.255.255.255    broadcasthost<br />
::1                            localhost</code><br />
And add this line after it:<br />
<code>127.0.0.1                devsite</code></li>
<li>Restart Apache<br />
<code>$ sudo apachectl restart</code></li>
</ol>
<p>You can now view your local files in your browser at <a href="http://devsite" title="This link will only work AFTER you finish the tutorial">http://devsite</a>.</p>
<p>Let&#8217;s step back and look at what we&#8217;ve done and why this is so useful.</p>
<p>Most likely, until now, you were viewing local development sites by going to something like <em>http://localhost/~yourname/devsite/fancy/url</em> (or <em>127.0.0.1</em> instead of <em>localhost</em>) and doing anything with mod_rewrite meant lots of <code>base href</code> tags and <code>RewriteBase</code> configurations, which in turn meant lots of ../../ paths before your images or included scripts to make things work. Now, viewing the same files in your browser is as easy as <em>http://devsite/fancy/url</em> and all of your paths can begin with a single slash ( / ) meaning it will still work the same when you migrate your site to the live server. Root relative paths are a life saver &#8211; and this setup makes it possible.</p>
<p>It&#8217;s also useful for quick access to commonly used tools, like <a href="http://phpmyadmin.net" title="phpMyAdmin" target="_blank">phpMyAdmin</a>. What I&#8217;ve done is install phpMyAdmin in /Users/me/Sites/phpMyAdmin and set up a Virtual Host like this:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
DocumentRoot /Users/me/Sites/phpMyAdmin<br />
ServerName admin<br />
&lt;/VirtualHost&gt;</code></p>
<p>In the <code>/etc/hosts</code> file:<br />
<code>127.0.0.1    admin</code></p>
<p>And I can always get to my phpMyAdmin install by simply typing <em>http://admin</em> into the browser.</p>
<p>The reason <em>http://admin</em> works is because most operating systems (even Windows!) will look at the local <code>hosts</code> file first before requesting information from DNS servers. Apache is told to handle requests to <em>http://admin</em> through the Virtual Host we set up. And all of this is done without www&#8217;s or .com&#8217;s.</p>
<p>By now you should realize that you can add as many Virtual Hosts as you like for as many sites as you need. All you need is these three commands:<br />
<code>$ mate /etc/httpd/users/yourname.conf<br />
$ mate /etc/hosts<br />
$ sudo apachectl restart</code></p>
<p>This can also be done on Windows, but it takes a little more work, and would of course work the same as described above on Linux/UNIX. If anyone would find it useful, let me know and I&#8217;ll post a new tutorial on the same method for Windows developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/10/04/save-time-and-code-using-virtual-hosts-for-local-os-x-web-development-with-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Show Hidden Files in OS X&#8217;s Finder</title>
		<link>http://michaelkrol.com/2007/10/01/show-hidden-files-in-os-x-finder/</link>
		<comments>http://michaelkrol.com/2007/10/01/show-hidden-files-in-os-x-finder/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 04:31:22 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[OS X]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/10/01/show-hidden-files-in-finder/</guid>
		<description><![CDATA[In web development on the Apache web server, a common configuration file used in nearly every site we build is the .htaccess file. But in OS X, you can&#8217;t see it in the Finder &#8211; hidden files (files which start with a dot &#8220;.&#8221;) are unavailable unless you use the Unix command line. I did ]]></description>
			<content:encoded><![CDATA[<p>In web development on the Apache web server, a common configuration file used in nearly every site we build is the <a href="http://en.wikipedia.org/wiki/Htaccess" title=".htaccess on Wikipedia">.htaccess</a> file. But in OS X, you can&#8217;t see it in the Finder &#8211; hidden files (files which start with a dot &#8220;.&#8221;) are unavailable unless you use the Unix command line. I did some digging around and found a way to enable hidden files in the Finder &#8211; which, ironically involves using the command line to get there.</p>
<p>Open the Terminal application (or, I much prefer <a href="http://iterm.sourceforge.net/" title="iTerm terminal emulation program">iTerm</a>) and type the following:<br />
<code>defaults write com.apple.finder AppleShowAllFiles TRUE</code><br />
and after hitting return, follow it up with<br />
<code>killall Finder</code><br />
which restarts the Finder and shows all files.</p>
<p><img src="http://michaelkrol.com/wp-content/uploads/2007/10/hidden_files_in_finder.jpg" alt="Hidden files in the OS X Finder" /></p>
<p>To revert back to hiding those files, simply run the same command above again but change <code>TRUE</code> to <code>FALSE</code></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/10/01/show-hidden-files-in-os-x-finder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change Your Domain Name and Keep Your Incoming Links With .htaccess And mod_rewrite</title>
		<link>http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/</link>
		<comments>http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/#comments</comments>
		<pubDate>Wed, 12 Sep 2007 20:56:06 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/</guid>
		<description><![CDATA[When moving our site from ablogapart.org to michaelkrol.com, this handy little bit helped move our entire website with four lines of code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)ablogapart.org [NC]
RewriteRule ^(.*)$ http://michaelkrol.com/$1 [R=301,L]
This reference was extremely helpful.
This RewriteRule lives in the .htaccess file at ablogapart.org and tells any request coming in to that domain to swap ablogapart.org out ]]></description>
			<content:encoded><![CDATA[<p>When moving our site from ablogapart.org to michaelkrol.com, this handy little bit helped move our entire website with four lines of code:</p>
<p><code>Options +FollowSymLinks<br />
RewriteEngine on<br />
RewriteCond %{HTTP_HOST} ^(.*)ablogapart.org [NC]<br />
RewriteRule ^(.*)$ http://michaelkrol.com/$1 [R=301,L]</code></p>
<p><a href="http://www.ilovejackdaniels.com/cheat-sheets/mod_rewrite-cheat-sheet/" title="mod_rewrite cheat sheet" target="_blank">This reference</a> was extremely helpful.</p>
<p>This RewriteRule lives in the .htaccess file at ablogapart.org and tells any request coming in to that domain to swap <em>ablogapart.org</em> out and replace it with <em>michaelkrol.com</em>. This includes ANYTHING after the trailing slash, like a direct link to a previous post. So http://ablogapart.org/this/direct/link gets sent properly to http://michaelkrol.com/this/direct/link</p>
<p>The important part is the <code>[R=301]</code> which sends a 301 (Permanent) Redirect header. That tells search engines that the page has moved permanently.</p>
<p>Just imagine what you&#8217;d have to go through setting up individual forwarding links&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2007/09/12/change-your-domain-name-and-keep-your-incoming-links-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Enable mod_rewrite on OS X 10.4 (Tiger)</title>
		<link>http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/</link>
		<comments>http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/#comments</comments>
		<pubDate>Tue, 22 Nov 2005 06:35:15 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Fixit]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=6</guid>
		<description><![CDATA[Tiger has introduced a new super-confusion level to the stock configuration of Apache. In addition to the httpd.conf file in the /etc/httpd directory, there&#8217;s now a new users directory as well. That directory holds unique config files for each user of the machine. So, if you were to enable mod_rewrite or AllowOverrides in httpd.conf, you ]]></description>
			<content:encoded><![CDATA[<p>Tiger has introduced a new super-confusion level to the stock configuration of Apache. In addition to the httpd.conf file in the <code>/etc/httpd</code> directory, there&#8217;s now a new <code>users</code> directory as well. That directory holds unique config files for each user of the machine. So, if you were to enable mod_rewrite or AllowOverrides in httpd.conf, you may find that it doesn&#8217;t quite cut the mustard in your personal Sites directory. Let&#8217;s take a look:</p>
<p>To enable mod_rewrite:</p>
<ol>
<li>Open <code>/etc/httpd/httpd.conf</code><br />
(I highly recommend <a href="http://macromates.com/" target="_blank">TextMate</a> &#8211; from the command line you can simply type this:<br />
<code>$ mate /etc/httpd/httpd.conf</code><br />
or use the old standards: vi, vim, whathaveyou)</li>
<li>Go to line 223 (if your config file just so happens to jive with mine) and uncomment the following line:<br />
<code>LoadModule rewrite_module     libexec/httpd/mod_rewrite.so</code><br />
(mind the wrap)</li>
<li>Go to line 267 and uncomment the following line:<br />
<code>AddModule mod_rewrite.c</code></li>
<li>Scroll down to line 408 and change the line to read:<br />
<code>AllowOverride All</code><br />
(Some server admins will tell you this may not be the best idea for hosting a live site, but I&#8217;m assuming you&#8217;re using this for local development only, right?)</li>
<li>Uncomment line 454:<br />
<code>AccessFileName .htaccess</code></li>
<li>Restart Apache:<br />
<code>$ sudo apachectl restart</code></li>
</ol>
<p>At this point you should have mod_rewrite happily fixing your ugly URL&#8217;s in the <code>/Library/WebServer/Documents</code> directory, but it&#8217;s not working in your <code>/Users/you/Sites</code> directory. What gives? Here&#8217;s the trick:</p>
<ol>
<li>Open the <code>yourname.conf</code> file in the <code>/etc/httpd/users</code> folder.</li>
<li>Change the first two lines to this:<br />
<code>    Options All<br />
AllowOverride All</code></li>
<li>Give Apache another bounce:<br />
<code>$ sudo apachectl restart</code></li>
</ol>
<p>You should now be seeing friendly url&#8217;s in your very own Sites directory.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2005/11/21/enable-mod_rewrite-on-os-x-104-tiger/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>
