<?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>Gittr &#187; Linux</title>
	<atom:link href="http://www.gittr.com/index.php/archive/category/system-admin/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gittr.com</link>
	<description>eval("eval(\"eval(\\\"puts 'a ruby weblog'\\\")\")")</description>
	<lastBuildDate>Thu, 22 Oct 2009 12:54:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Deploying Sinatra via Thin and Lighttpd</title>
		<link>http://www.gittr.com/index.php/archive/deploying-sinatra-via-thin-and-lighttpd/</link>
		<comments>http://www.gittr.com/index.php/archive/deploying-sinatra-via-thin-and-lighttpd/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 03:00:02 +0000</pubDate>
		<dc:creator>cschneid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Sinatra]]></category>
		<category><![CDATA[System Admin]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=34</guid>
		<description><![CDATA[
I&#8217;ve previously written about deploying Sinatra to Dreamhost, both with FastCGI, and also Passenger (mod_rails).  This howto will cover how to deploy Sinatra to a load-balanced reverse-proxy setup using Lighttpd and&#160;Thin.


1) Install Lighttpd and&#160;Thin

# Figure out lighttpd yourself, it should be handled by your 
# linux distro's package manager
&#160;
# For thin:
gem install thin



2) Create [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve previously written about deploying Sinatra to Dreamhost, both with <a href="http://www.gittr.com/index.php/archive/deploying-a-simple-sinatra-application-on-dreamhost-via-fastcgi/">FastCGI</a>, and also <a href="http://www.gittr.com/index.php/archive/deploying-rack-apps-on-dreamhost-via-passenger-including-sinatra/">Passenge</a>r (mod_rails).  This howto will cover how to deploy Sinatra to a load-balanced reverse-proxy setup using Lighttpd and&nbsp;Thin.
</p>
<p>
<strong>1) Install Lighttpd and&nbsp;Thin</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Figure out lighttpd yourself, it should be handled by your </span>
<span style="color:#008000; font-style:italic;"># linux distro's package manager</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># For thin:</span>
gem install thin</pre></div></div>

</p>
<p>
<strong>2) Create your rackup file</strong> - the &#8220;require &#8216;app&#8217;&#8221; line should require the actual sinatra app you have&nbsp;written.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span>
&nbsp;
<span style="color:#6666ff; font-weight:bold;">Sinatra::Application</span>.<span style="color:#9900CC;">default_options</span>.<span style="color:#9900CC;">merge</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>
  <span style="color:#ff3333; font-weight:bold;">:run</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">false</span>,
  <span style="color:#ff3333; font-weight:bold;">:env</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:production</span>
<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'app'</span>
run Sinatra.<span style="color:#9900CC;">application</span></pre></div></div>

</p>
<p>
<strong>3) Setup a config.yml</strong> - change the /path/to/my/app path to reflect&nbsp;reality.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#006600; font-weight:bold;">---</span>
    environment: production
    chdir: <span style="color:#006600; font-weight:bold;">/</span>path<span style="color:#006600; font-weight:bold;">/</span>to<span style="color:#006600; font-weight:bold;">/</span>my<span style="color:#006600; font-weight:bold;">/</span>app
    address: 127.0.0.1
    user: root
    group: root
    port: <span style="color:#006666;">4567</span>
    pid: <span style="color:#006600; font-weight:bold;">/</span>path<span style="color:#006600; font-weight:bold;">/</span>to<span style="color:#006600; font-weight:bold;">/</span>my<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>thin.<span style="color:#9900CC;">pid</span>
    rackup: <span style="color:#006600; font-weight:bold;">/</span>path<span style="color:#006600; font-weight:bold;">/</span>to<span style="color:#006600; font-weight:bold;">/</span>my<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>config.<span style="color:#9900CC;">ru</span>
    log: <span style="color:#006600; font-weight:bold;">/</span>path<span style="color:#006600; font-weight:bold;">/</span>to<span style="color:#006600; font-weight:bold;">/</span>my<span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>thin.<span style="color:#9900CC;">log</span>
    max_conns: <span style="color:#006666;">1024</span>
    timeout: <span style="color:#006666;">30</span>
    max_persistent_conns: <span style="color:#006666;">512</span>
    daemonize: <span style="color:#0000FF; font-weight:bold;">true</span></pre></div></div>

</p>
<p>
<strong>4) Setup lighttpd.conf</strong> - change mydomain to reflect reality.  Also make sure the first port here matches up with the port setting in&nbsp;config.yml.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#ff6633; font-weight:bold;">$<span class="caps">HTTP</span></span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;host&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> =~ <span style="color:#996600;">&quot;(www<span style="color:#000099;">\.</span>)?mydomain<span style="color:#000099;">\.</span>com&quot;</span>  <span style="color:#006600; font-weight:bold;">&#123;</span>
        proxy.<span style="color:#9900CC;">balance</span> = <span style="color:#996600;">&quot;fair&quot;</span>
        proxy.<span style="color:#9900CC;">server</span> =  <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;/&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span>
                                <span style="color:#006600; font-weight:bold;">&#40;</span>
                                        <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;host&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;127.0.0.1&quot;</span>, <span style="color:#996600;">&quot;port&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">4567</span> <span style="color:#006600; font-weight:bold;">&#41;</span>,
                                        <span style="color:#006600; font-weight:bold;">&#40;</span> <span style="color:#996600;">&quot;host&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;127.0.0.1&quot;</span>, <span style="color:#996600;">&quot;port&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">4568</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
                                <span style="color:#006600; font-weight:bold;">&#41;</span>
                        <span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

</p>
<p>
<strong>5) Start thin and your application </strong>. I have a rake script so I can just call &#8220;rake start&#8221; rather than typing this in.  It&#8217;s just a few lines to do&nbsp;that.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">thin <span style="color:#006600; font-weight:bold;">-</span>s <span style="color:#006666;">2</span> <span style="color:#006600; font-weight:bold;">-</span>C config.<span style="color:#9900CC;">yml</span> <span style="color:#006600; font-weight:bold;">-</span>R config.<span style="color:#9900CC;">ru</span> start</pre></div></div>

</p>
<p><strong>Go to mydomain.com/ and see the result!</strong> Everything should be setup now, check it out at the domain you setup in your lighttpd.conf&nbsp;file.</p>
<p>
<strong>Variations - nginx</strong> - I haven&#8217;t looked into the config file syntax, but there isn&#8217;t any reason that this exact same approach wouldn&#8217;t work with nginx.  Thin and the rackup file stay the same, while the nginx layer has to be configured to reverse proxy to the thin&nbsp;install.</p>
<p>
<strong>Variations - More Thin instances</strong> - To add more thin instances, change the -s 2 parameter on the thin start command to be how ever many servers you want.  Then be sure lighttpd proxies to all of them by adding more lines to the proxy statements.  Then restart lighttpd and you&#8217;re&nbsp;done.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/deploying-sinatra-via-thin-and-lighttpd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting up PECL-APC on Lighttpd and Gentoo</title>
		<link>http://www.gittr.com/index.php/archive/setting-up-pecl-apc-on-lighttpd-and-gentoo/</link>
		<comments>http://www.gittr.com/index.php/archive/setting-up-pecl-apc-on-lighttpd-and-gentoo/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 01:59:44 +0000</pubDate>
		<dc:creator>cschneid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[System Admin]]></category>

		<guid isPermaLink="false">http://www.gittr.com/?p=7</guid>
		<description><![CDATA[Since I&#8217;m using Slicehost for my VPS hosting, and I&#8217;m cheap, I only have 256 megs of ram to work with.  I run lighttpd, which then forces me to use php-cgi (via fastcgi) as the php executable.  All of this is then running on&#160;Gentoo.
Anyway, what I&#8217;m getting to is how to setup PECL-APC [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m using <a href="http://www.slicehost.com" target="_self">Slicehost</a> for my <span class="caps">VPS</span> hosting, and I&#8217;m cheap, I only have 256 megs of ram to work with.  I run lighttpd, which then forces me to use php-cgi (via fastcgi) as the php executable.  All of this is then running on&nbsp;Gentoo.</p>
<p>Anyway, what I&#8217;m getting to is how to setup <span class="caps">PECL</span>-<span class="caps">APC</span> (php accelerator / bytecode cache) on this&nbsp;platform.</p>
<p>Turns out all the scary messages in FAQs saying <span class="caps">APC</span> doesn&#8217;t work with <span class="caps">CGI</span> interfaces don&#8217;t apply to the fast-cgi implementation that Lighttpd uses.<br />
<code lang="sh"><br />
emerge -uDv php5/pecl-apc<br />
</code></p>
<p>And then you&#8217;re&nbsp;done.</p>
<p>Hopefully my rambling was enough to get you going.  To tweak, go check out&nbsp;/etc/php/php5-cgi/ext/apc.ini</p>
<p>Also, to verify this whole thing, you need a phpinfo() page&#8230;&nbsp;like:</p>
<p><code lang="php"><br />
&lt;?php phpinfo(); ?&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gittr.com/index.php/archive/setting-up-pecl-apc-on-lighttpd-and-gentoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
