<?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>ReadyState4 &#187; Apache</title>
	<atom:link href="http://readystate4.com/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://readystate4.com</link>
	<description>JavaScript, Web Development, Ruby, and Technology.</description>
	<lastBuildDate>Fri, 04 Jun 2010 19:42:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to add Ruby (.rhtml) support to your existing MAMP setup with eRuby</title>
		<link>http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/</link>
		<comments>http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 02:30:50 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/</guid>
		<description><![CDATA[Adding Ruby HTML support to your existing MAMP setup is great for experimenting and for building quick single serving apps where a whole Rails setup would be overkill. This is how I added Ruby RHTML page support to my current MAMP setup:
Download and compile eRuby

Download and unzip http://www.modruby.net/en/index.rbx/eruby/download.html
Go to the unzipped directory in terminal
type ./configure.rb
type [...]]]></description>
			<content:encoded><![CDATA[<p>Adding Ruby HTML support to your existing <a href="http://www.mamp.info/en/index.php">MAMP</a> setup is great for experimenting and for building quick single serving apps where a whole Rails setup would be overkill. This is how I added Ruby RHTML page support to my current MAMP setup:</p>
<h3>Download and compile eRuby</h3>
<ol>
<li>Download and unzip <a href="http://www.modruby.net/en/index.rbx/eruby/download.html">http://www.modruby.net/en/index.rbx/eruby/download.html</a></li>
<li>Go to the unzipped directory in terminal</li>
<li>type ./configure.rb</li>
<li>type make</li>
<li>type make install</li>
<li>Copy the generated eruby file to your local cgi-bin</li>
</ol>
<h3>Modify your httpd.conf settings</h3>
<ol>
<li>add this line to add the rhtml support:
<pre>AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby</pre>
</li>
<li>And modify this line so your server will look for index.rhtml pages in directories:<br />
<code>DirectoryIndex index.html index.shtml index.rhtml</code></li>
</ol>
<h3>Running straight .rb files outside your cgi-bin folder (optional)</h3>
<p>You can run any scripts from your cgi-bin if you properly add the #!(she bang) location to your ruby intepreter at the top of your scripts, but you can also make these scrips run outside of your cgi-bin by just adding this line to your httpd.config, just add the .rb extension to the filename:</p>
<pre>AddHandler cgi-script .rb</pre>
<p>I was doing this for awhile so I could execute scripts through the web but the RHTML method is better. Still, there could be applicable reasons for a person to want to do this.  Just keep in mind, that when accessing Ruby scripts directly from a webpage you must at least specify a content-type (puts: &#8220;content-type: text/plain\n&#8221;) in your header or use the convenient <a href="http://www.ruby-doc.org/stdlib/libdoc/cgi/rdoc/index.html">cgi class</a> from the Ruby standard library that does that (and a whole lot more) for you.</p>
<h3>Improving Performance (optional)</h3>
<p>The above is a really quick way to add Ruby support to your local webserver however, there&#8217;s one downside &#8211; it has to start up the Ruby interpreter everytime you hit an rhtml file with your browser. If you want something a little more dedicated look into the <a href="http://modruby.net/en/">mod_ruby</a> apache module which embeds a Ruby interpreter into Apache&#8217;s (inside your web server&#8217;s memory), to let Ruby CGI scripts execute natively, so scripts start up and run far faster. This is the equivalent as mod_php for PHP, that&#8217;s built into your MAMP setup.</p>
<p>Additionally, as a speed boost, you could use <a href="http://www.fastcgi.com/">fast cgi</a> to keep the eRuby interpreter instantiated, if for some reason you can&#8217;t use mod_ruby.</p>
<p><strong>Helpful links:</strong></p>
<p>http://www.rubycentral.com/book/web.html</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/08/18/how-to-add-ruby-rhtml-support-to-your-existing-mamp-setup-with-eruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
