<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[crigor.com]]></title>
  <link href="http://crigor.com/atom.xml" rel="self"/>
  <link href="http://crigor.com/"/>
  <updated>2012-02-10T23:09:18+08:00</updated>
  <id>http://crigor.com/</id>
  <author>
    <name><![CDATA[Christopher Rigor]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Adding Nginx Vim Highlights on Janus]]></title>
    <link href="http://crigor.com/adding-nginx-vim-highlights-on-janus/"/>
    <updated>2012-02-10T22:45:00+08:00</updated>
    <id>http://crigor.com/adding-nginx-vim-highlights-on-janus</id>
    <content type="html"><![CDATA[<p>I&#8217;m using Janus to save time in setting up my vim environment. It installs plugins like Ack, NerdTree, CtrlP and many others. It has syntax highlighting for ruby, javascript, and other languages. It doesn&#8217;t have syntax highlighting for nginx though, which is the web server I personally use and at Engine Yard. Sometimes I write the nginx config in my local machine before copying it to the remote server. Having syntax highlighting definitely helps.</p>

<p>A quick search leads me to this <a href="http://www.vim.org/scripts/script.php?script_id=1886">nginx.vim</a>. The instructions say to add that file to <code>~/.vim/syntax</code>. Since I&#8217;m using Janus, any modifications should be done on <code>~/.janus</code> and not on <code>~/.vim</code>. However, adding nginx.vim to <code>~/.janus</code> doesn&#8217;t work. You should instead make a new directory on <code>~/.janus</code> and add a <code>syntax</code> subdirectory.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>mkdir -p ~/.janus/nginx/syntax
</span><span class='line'>cp /path/to/nginx.vim ~/.janus/nginx/syntax/</span></code></pre></td></tr></table></div></figure>


<p>Then on your <code>~/.vimrc.after</code> add <code>au BufRead,BufNewFile *.conf set ft=nginx</code></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Macvim and Upgrading Janus]]></title>
    <link href="http://crigor.com/macvim-upgrading-janus/"/>
    <updated>2012-02-03T15:29:29+08:00</updated>
    <id>http://crigor.com/macvim-upgrading-janus</id>
    <content type="html"><![CDATA[<p>In true developer fashion, I decided to spend more hours working on my tools than coding. Tonight, it&#8217;s time to upgrade Janus. <a href="https://github.com/carlhuda/janus">Janus</a> is a collection of vim plugins. It sets up your vim environment with a few commands.</p>

<p>I followed the instructions on how to upgrade Janus. I ran curl -Lo- http://bit.ly/janus-bootstrap | bash and expected everything to work. I typed mvim and got this</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Error detected while processing function janus#load_pathogen:
</span><span class='line'>line    3:
</span><span class='line'>E484: Can't open file /Users/crigor/.vim/janus/vim/core/pathogen/autoload/pathogen.vim</span></code></pre></td></tr></table></div></figure>


<p>True enough that file doesn&#8217;t exist. In fact, the directory /Users/crigor/.vim/janus/vim/core/pathogen/autoload doesn&#8217;t exist. After checking the source code of Janus, I found out that pathogen is a git submodule. Something is not set up correctly if the submodule doesn&#8217;t exist. Maybe it&#8217;s time to look at the output of that curl command.</p>

<p>Aha! I didn&#8217;t notice that there was a git error when I installed Janus.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>fatal: reference is not a tree: 47e897d92f47196017ab00281919a8bcd71e1cd3
</span><span class='line'>Unable to checkout '47e897d92f47196017ab00281919a8bcd71e1cd3' in submodule path 'janus/vim/colors/getafe'</span></code></pre></td></tr></table></div></figure>


<p>Instead of trying to find out what&#8217;s wrong with that submodule, I just deleted it with</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>git rm janus/vim/colors/getafe</span></code></pre></td></tr></table></div></figure>


<p>. Then I didn&#8217;t want to run rake on the ~/.vim because that would just clone the Janus repo again and try to install the getafe submodule. I ran</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>git submodule init
</span><span class='line'>git submodule update</span></code></pre></td></tr></table></div></figure>


<p>After all the submodules were updated, including the pathogen submodule, I ran</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>rake install</span></code></pre></td></tr></table></div></figure>


<p>After I added a few custom settings on ~/.vimrc.before and ~/.vimrc.after, my new macvim environment is set.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Contributing to Rubinius]]></title>
    <link href="http://crigor.com/contributing-to-rubinius/"/>
    <updated>2011-10-19T07:55:00+08:00</updated>
    <id>http://crigor.com/contributing-to-rubinius</id>
    <content type="html"><![CDATA[<p>I was at the Engine Yard office today and Brian Ford gave a talk on Rubinius. One of the things he mentioned is contributing to Rubinius. If you have an application running on MRI , try running it on Rubinius. The Rubinius team wants Rubinius to be a drop-in replacement for MRI. If your application doesn&#8217;t run correctly, it is considered a bug and you should report it.</p>

<p>Brian also wrote a blog post about it today. <a href="http://rubini.us/2011/10/18/contributing-to-rubinius/">http://rubini.us/2011/10/18/contributing-to-rubinius/</a></p>

<p>rvm install rbx
rvm use rbx
gem install bundler
cd myapplication
rm Gemfile.lock
bundle install</p>

<p>Rubinius is written in Ruby. One of the advantages of this is optimization. Your code, plus the code that runs your code can be optimized which will make your code faster. In reality though, you still need to test your app with Rubinius and compare its speed when running MRI.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Illformed requirement Syck::DefaultKey]]></title>
    <link href="http://crigor.com/illformed-requirement-syck-defaultkey/"/>
    <updated>2011-09-14T14:30:22+08:00</updated>
    <id>http://crigor.com/illformed-requirement-syck-defaultkey</id>
    <content type="html"><![CDATA[<p>If you&#8217;re getting the errors below, you should update rubygems to the latest, which is 1.8.10 as of this writing.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Installing cucumber-rails (1.0.4) Invalid gemspec in [/Users/crigor/.rvm/gems/ruby-1.9.2-p180@ss/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement [&quot;#&lt;Syck::DefaultKey:0x00000100e779e8&gt; 0.7.2&quot;]
</span><span class='line'>
</span><span class='line'>Installing database_cleaner (0.6.7) Invalid gemspec in
</span><span class='line'>[/Users/crigor/.rvm/gems/ruby-1.9.2-p180@ss/specifications/cucumber-rails-1.0.4.gemspec]: Illformed requirement [&quot;#&lt;Syck::DefaultKey:0x00000100e779e8&gt; 0.7.2&quot;]</span></code></pre></td></tr></table></div></figure>


<p>Check out <a href="http://blog.rubygems.org/2011/08/31/shaving-the-yaml-yacc.html"> http://blog.rubygems.org/2011/08/31/shaving-the-yaml-yacc.html</a> to get the details. After upgrading rubygems to 1.8.10, I was able to install database_cleaner but I was still getting an error for cucumber-rails. The solution is to open /Users/crigor/.rvm/gems/ruby-1.9.2-p180@ss/specifications/cucumber-rails-1.0.4.gemspec and change</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>#&lt;Syck::DefaultKey:0x00000100e779e8&gt;</span></code></pre></td></tr></table></div></figure>


<p> to =. If you&#8217;re using vim, just run</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>:%s/#&lt;Syck.*&gt;/=/</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Sync Time in Ubuntu]]></title>
    <link href="http://crigor.com/sync-time-in-ubuntu/"/>
    <updated>2011-08-29T11:59:18+08:00</updated>
    <id>http://crigor.com/sync-time-in-ubuntu</id>
    <content type="html"><![CDATA[<p>The time on my ubuntu server is out of sync. It&#8217;s 15 minutes ahead! To fix it, I ran ntpdate ntp.ubuntu.com.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Rack Middleware]]></title>
    <link href="http://crigor.com/rack-middleware/"/>
    <updated>2011-04-19T13:14:24+08:00</updated>
    <id>http://crigor.com/rack-middleware</id>
    <content type="html"><![CDATA[<p>A rack middleware is a piece of code that sits on top of your rack application. It has access to the request and other environment variables. It can do different things like return a response without going to the rack application or insert some data that will be used by the rack application.</p>

<p>A rack middleware is a class that needs an initialize method and a call method. The initialize method has at least one argument, the application. This application can be another middleware on the &#8216;chain&#8217; or the rack application.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">app</span><span class="p">)</span>
</span><span class='line'>  <span class="vi">@app</span> <span class="o">=</span> <span class="n">app</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>The call method has one argument, the environment and should return an array with 3 elements - the status, the headers, and the body. The status should be an integer, the headers should respond to each, and the body should respond to each as well.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'>  <span class="k">def</span> <span class="nf">call</span><span class="p">(</span><span class="n">env</span><span class="p">)</span>
</span><span class='line'>    <span class="k">if</span> <span class="n">env</span><span class="o">[</span><span class="s1">&#39;PATH_INFO&#39;</span><span class="o">]</span> <span class="o">==</span> <span class="s1">&#39;/rubyinfo&#39;</span>
</span><span class='line'>      <span class="no">Rack</span><span class="o">::</span><span class="no">Response</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="o">[</span><span class="vg">$&amp;</span><span class="n">quot</span><span class="p">;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="o">&amp;</span><span class="n">quot</span><span class="p">;</span><span class="o">&amp;</span><span class="n">lt</span><span class="p">;</span><span class="n">br</span><span class="sr"> /&amp;gt;&amp;quot;)], 200).to_a</span>
</span><span class='line'><span class="sr">    else</span>
</span><span class='line'><span class="sr">      @app.call(env) </span>
</span><span class='line'><span class="sr">    end</span>
</span><span class='line'><span class="sr">  end</span>
</span></code></pre></td></tr></table></div></figure>


<p>In this example, the middleware will check if the request is for /rubyinfo. If it is, it will return a response. If it&#8217;s not, it will pass the request to the rack application.</p>

<p>To add a rack middleware, use &#8216;use&#8217;</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">use</span> <span class="no">RubyInfo</span>
</span><span class='line'><span class="n">run</span> <span class="no">MyRackApplication</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[jQuery Submit]]></title>
    <link href="http://crigor.com/jquery-submit/"/>
    <updated>2010-10-27T14:16:17+08:00</updated>
    <id>http://crigor.com/jquery-submit</id>
    <content type="html"><![CDATA[<p>When you submit a form, you might want to do something before the form is submitted. In the code below, we show an alert box with the value of the text field &#8216;name&#8217;.</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#my-form&#39;</span><span class="p">).</span><span class="nx">submit</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="nx">alert</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#name&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">());</span>
</span><span class='line'><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Find and Move]]></title>
    <link href="http://crigor.com/find-and-move/"/>
    <updated>2010-10-25T15:25:36+08:00</updated>
    <id>http://crigor.com/find-and-move</id>
    <content type="html"><![CDATA[<p>find . -name &#8220;*\ 1.JPG&#8221; -print0 | xargs -0 -I {} mv {} newdir</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Redmine on Jruby]]></title>
    <link href="http://crigor.com/redmine-on-jruby/"/>
    <updated>2010-09-28T14:06:01+08:00</updated>
    <id>http://crigor.com/redmine-on-jruby</id>
    <content type="html"><![CDATA[<p>To be able to take advantage of jruby, you need to add config.threadsafe! on your rails app. I tried doing this on redmine 1.0.2 but some pages were not working. Some of the errors were</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">uninitialized</span> <span class="n">constant</span> <span class="no">Redmine</span><span class="o">::</span><span class="no">Views</span><span class="o">::</span><span class="no">OtherFormatsBuilder</span>
</span><span class='line'><span class="n">uninitialized</span> <span class="n">constant</span> <span class="no">Redmine</span><span class="o">::</span><span class="no">DefaultData</span>
</span><span class='line'><span class="n">uninitialized</span> <span class="n">constant</span> <span class="no">Redmine</span><span class="o">::</span><span class="no">Activity</span><span class="o">::</span><span class="no">Fetcher</span>
</span><span class='line'><span class="n">uninitialized</span> <span class="n">constant</span> <span class="no">ActionView</span><span class="o">::</span><span class="no">Base</span><span class="o">::</span><span class="no">CompiledTemplates</span><span class="o">::</span><span class="no">TabularFormBuilder</span>
</span></code></pre></td></tr></table></div></figure>


<p>I got it to work by changing config/initializers/30-redmine.rb to</p>

<figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">I18n</span><span class="o">.</span><span class="n">default_locale</span> <span class="o">=</span> <span class="s1">&#39;en&#39;</span>
</span><span class='line'><span class="n">dirs</span> <span class="o">=</span> <span class="o">[</span><span class="s2">&quot;SVG&quot;</span><span class="p">,</span> <span class="s2">&quot;redmine&quot;</span><span class="o">]</span>
</span><span class='line'><span class="n">files</span> <span class="o">=</span> <span class="o">[]</span>
</span><span class='line'><span class="n">lib_path</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="no">RAILS_ROOT</span><span class="si">}</span><span class="s2">/lib&quot;</span>
</span><span class='line'><span class="n">matcher</span> <span class="o">=</span> <span class="sr">/\A</span><span class="si">#{</span><span class="no">Regexp</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="n">lib_path</span><span class="p">)</span><span class="si">}</span><span class="sr">\/(.*)\.rb\Z/</span>
</span><span class='line'><span class="n">dirs</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">dir</span><span class="o">|</span>
</span><span class='line'>  <span class="n">files</span> <span class="o">+=</span> <span class="no">Dir</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">#{</span><span class="n">lib_path</span><span class="si">}</span><span class="s2">/</span><span class="si">#{</span><span class="n">dir</span><span class="si">}</span><span class="s2">/**/*.rb&quot;</span><span class="p">)</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'><span class="n">files</span> <span class="o">+=</span> <span class="no">Dir</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">#{</span><span class="n">lib_path</span><span class="si">}</span><span class="s2">/*.rb&quot;</span><span class="p">)</span>
</span><span class='line'><span class="n">files</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">file</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">require</span> <span class="n">file</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="n">matcher</span><span class="p">,</span> <span class="s1">&#39;\1&#39;</span><span class="p">)</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Adding RAILS_ROOT/lib to config.eager_load_paths doesn&#8217;t work. If there is a better way, let me know in the comments.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Installing Nginx with Passenger on Snow Leopard Using MacPorts]]></title>
    <link href="http://crigor.com/nginx-passenger-snow-leopard-macports/"/>
    <updated>2009-12-20T09:18:44+08:00</updated>
    <id>http://crigor.com/nginx-passenger-snow-leopard-macports</id>
    <content type="html"><![CDATA[<p><a href="http://www.macports.org/install.php">Install MacPorts</a> if you don&#8217;t have it.</p>

<p>Download and install the Portfile</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>git clone git://github.com:crigor/admoolabs-ports.git ports
</span><span class='line'>cd ports/nginx-0.7.64-passenger-2.2.8
</span><span class='line'>sudo port -v install</span></code></pre></td></tr></table></div></figure>


<p>You need to have ruby installed to compile passenger. In case you don&#8217;t have ruby, you can also get it from macports.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo port -v install ruby</span></code></pre></td></tr></table></div></figure>


<p>If you have an older version of nginx installed using macports, it might move nginx.conf to nginx.conf.altered. Copy it back to nginx.conf if you need it. You can also use this <a href="http://gist.github.com/258789">nginx.conf</a>.</p>

<p>Edit /opt/local/etc/nginx.conf and add the following lines inside http {}</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>passenger_root /opt/local/lib/passenger;
</span><span class='line'>passenger_ruby /opt/local/bin/ruby;</span></code></pre></td></tr></table></div></figure>


<p>Change the ruby path if you&#8217;re not using ruby from macports.</p>

<p>For each rails app, you need to add the following, also inside http {}</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>server {
</span><span class='line'>  server_name labs.local;
</span><span class='line'>  root /Users/crigor/admoolabs/labs/public;
</span><span class='line'>  access_log /opt/local/var/log/nginx/labs.local.access.log;
</span><span class='line'>  error_log /opt/local/var/log/nginx/labs.local.error.log;
</span><span class='line'>  passenger_enabled on;
</span><span class='line'>  rails_env development;
</span><span class='line'>}</span></code></pre></td></tr></table></div></figure>


<p>Check if your syntax is correct.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo /opt/local/sbin/nginx -t</span></code></pre></td></tr></table></div></figure>


<p>If it is, you&#8217;ll see</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>the configuration file /opt/local/etc/nginx/nginx.conf syntax is ok
</span><span class='line'>configuration file /opt/local/etc/nginx/nginx.conf test is successful</span></code></pre></td></tr></table></div></figure>


<p>Start nginx with</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo /opt/local/sbin/nginx</span></code></pre></td></tr></table></div></figure>


<p>You won&#8217;t get any output if it starts correctly. Check if nginx is running</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>ps -e | grep nginx -i
</span><span class='line'>(You should see something like these lines)
</span><span class='line'>nginx: master process /opt/local/sbin/nginx
</span><span class='line'>nginx: worker process
</span><span class='line'>PassengerNginxHelperServer /opt/local/lib/passenger /opt/local/bin/ruby 3 4 0 6 0 300 1 nobody 4294967294 4294967294 /tmp/passenger.10755</span></code></pre></td></tr></table></div></figure>


<p>MacPorts added a startup item which is disabled by default. To start it,</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist</span></code></pre></td></tr></table></div></figure>


<p>You can stop nginx with</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo launchctl stop org.macports.nginx</span></code></pre></td></tr></table></div></figure>


<p>but it would just be started right away. If you want it to remain stopped, use</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo launchctl unload /Library/LaunchDaemons/org.macports.nginx.plist</span></code></pre></td></tr></table></div></figure>


<p>When you make changes to the config, reload the config with</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>sudo /opt/local/sbin/nginx -s reload</span></code></pre></td></tr></table></div></figure>


<p>Check the other nginx options using</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>/opt/local/sbin/nginx -h</span></code></pre></td></tr></table></div></figure>


<p>One more thing&#8230;
When you add a rails or rack app, you need to specify a different server_name. You need to add it to /etc/hosts</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>127.0.0.1 localhost labs.local</span></code></pre></td></tr></table></div></figure>


<p>Don&#8217;t you think it would be great if you can handle this automatically? Me too. Stay tuned for more. This shouldn&#8217;t be a <del>pane</del> pain. ;)</p>
]]></content>
  </entry>
  
</feed>

