<?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; Linux</title>
	<atom:link href="http://michaelkrol.com/category/linux/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>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>Creating a MySQL Dump File From an External Database</title>
		<link>http://michaelkrol.com/2006/03/16/creating-a-mysql-dump-file-from-an-external-database/</link>
		<comments>http://michaelkrol.com/2006/03/16/creating-a-mysql-dump-file-from-an-external-database/#comments</comments>
		<pubDate>Thu, 16 Mar 2006 19:20:34 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=11</guid>
		<description><![CDATA[I needed to export a MySQL database that was on a different server than the web server and was bound and determined to do it without going through the hassle of installing phpMyAdmin (port 3306 was blocked as well, so I couldn&#8217;t use any GUI tools either). The trick was adding the -h option. Here&#8217;s ]]></description>
			<content:encoded><![CDATA[<p>I needed to export a MySQL database that was on a different server than the web server and was bound and determined to do it without going through the hassle of installing phpMyAdmin (port 3306 was blocked as well, so I couldn&#8217;t use any GUI tools either). The trick was adding the <code>-h</code> option. Here&#8217;s the command line that made some magic:</p>
<p><code>mysqldump -u username -p -h dbserver.host.com --compatible=mysql40 dbname &gt; filetosave.sql</code></p>
<p>The <code>--compatible</code> command was added because the database server was running MySQL 4.1 and we needed the export for MySQL 4.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2006/03/16/creating-a-mysql-dump-file-from-an-external-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP mail() And Gmail &#8211; A Warning on Headers</title>
		<link>http://michaelkrol.com/2005/12/07/php-mail-and-gmail-a-warning-on-headers/</link>
		<comments>http://michaelkrol.com/2005/12/07/php-mail-and-gmail-a-warning-on-headers/#comments</comments>
		<pubDate>Thu, 08 Dec 2005 07:56:51 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Fixit]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://michaelkrol.com/?p=10</guid>
		<description><![CDATA[Today, out of nowhere, we started receiving reports that HTML email the gdiapers.com site was sending were showing up as just that: HTML code and not much else. Running a few tests confirmed these reports&#8230; but only in my gmail account. We went back and checked the reports and sure enough &#8211; they were all ]]></description>
			<content:encoded><![CDATA[<p>Today, out of nowhere, we started receiving reports that HTML email the <a href="http://www.gdiapers.com">gdiapers.com</a> site was sending were showing up as just that: HTML code and not much else. Running a few tests confirmed these reports&#8230; but only in my gmail account. We went back and checked the reports and sure enough &#8211; they were all coming from gmail users.</p>
<p>After some tinkering and futzing around we realized that the Windows line breaks that we had after the headers (<code>\r\n</code>) were the problem. Here&#8217;s an example:</p>
<p>This will show up as two line breaks in gmail and trash your HTML formatting:<br />
<code>$headers = "MIME-Version: 1.0\r\n";</code></p>
<p>This, however, will fix the problem and show up in gmail just fine:<br />
<code>$headers = "MIME-Version: 1.0\n";</code></p>
<p>I&#8217;m sure if you were sending mail from a Windows server this may not be the case, but for those on a Unix box, just stick with <code>\n</code>. Google will thank you by displaying your HTML email the way it was meant to be displayed &#8211; without raw code!</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelkrol.com/2005/12/07/php-mail-and-gmail-a-warning-on-headers/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
