<?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>по стопам webkill&#039;а &#187; mongrel</title>
	<atom:link href="http://blog.lukmus.ru/tag/mongrel/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lukmus.ru</link>
	<description>это наш химический дом для печальных жителей Земли</description>
	<lastBuildDate>Sat, 21 Oct 2023 19:10:13 +0000</lastBuildDate>
	<language>ru-RU</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>rails 3 на nginx+mongrel</title>
		<link>http://blog.lukmus.ru/2011/10/31/rails-3-na-nginxmongrel/</link>
		<comments>http://blog.lukmus.ru/2011/10/31/rails-3-na-nginxmongrel/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 08:21:21 +0000</pubDate>
		<dc:creator>lukmus</dc:creator>
				<category><![CDATA[ruby & ruby on rails]]></category>
		<category><![CDATA[настройка и установка]]></category>
		<category><![CDATA[mongrel]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ROR 3]]></category>
		<category><![CDATA[ruby on rails 3]]></category>

		<guid isPermaLink="false">http://blog.lukmus.ru/?p=1116</guid>
		<description><![CDATA[Некоторые люди, которым интересен iLukmus, наверняка заметили, что сайт работает, мягко говоря, нестабильно и падает по несколько раз в сутки. Я уже пробывал ставить сайт на Apache+Passenger и Nginx+Passenger, и в обоих этих вариантах ситуация с падениям web-сервера была идентичной. Вероятнее всего, я просто не умею их готовить их правильно настраивать, но проблему все равно [...]]]></description>
			<content:encoded><![CDATA[<p>Некоторые люди, которым интересен iLukmus, наверняка заметили, что сайт работает, мягко говоря, нестабильно и падает по несколько раз в сутки. Я уже пробывал ставить сайт на Apache+Passenger и Nginx+Passenger, и в обоих этих вариантах ситуация с падениям web-сервера была идентичной. Вероятнее всего, я просто не умею <del datetime="2011-10-31T06:32:59+00:00">их готовить</del> их правильно настраивать, но проблему все равно нужно решать, а т.к. пробывать различные конфиги мне уже надоело, iLukmus переходит на Mongrel+Nginx.<br />
<img class="aligncenter size-full wp-image-1117" title="commie-obama" src="http://blog.lukmus.ru/wp-content/uploads/2011/10/commie-obama.jpg" alt="" width="517" height="315" /><span id="more-1116"></span></p>
<h2>установка Mongrel</h2>
<p>Mongrel на ruby 1.9 устанавливается своеобразно, обычный способ с прописыванием гема в Gemfile рельсов здесь не прокатит и вызовет ошибку.<br />
Ставим гем Mongrel&#8217;а:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">gem install mongrel <span style="color: #339933;">--</span>pre</pre></td></tr></table></div>

<p>Прописываем гем в Gemfile ROR&#8217;а:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">gem <span style="color: #0000ff;">'mongrel'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;= 1.2.0.pre2'</span></pre></td></tr></table></div>

<p>Ну и забандлим новый гем:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">bundle install</pre></td></tr></table></div>

<p>Подробнее почему нужно ставить именно так и какая конкретно вылезает ошибка можно почитать <a rel="nofollow" href="http://kevin.h-pk-ns.com/2011/08/11/using-mongrel-on-ruby-1-9-2/" target="_blank">здесь</a>.</p>
<h2>установка и настройка Nginx</h2>
<h3>установка</h3>
<p>Предполагается, что <a href="http://blog.lukmus.ru/?p=1106">Nginx был установлен вместе с Passenger&#8217;ом</a>, но его можно установить и просто так:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install nginx</span></pre></td></tr></table></div>

<h3>настройка</h3>
<p>Теперь открываем файл конфига nginx.conf и прописываем, что-то типа:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">user  deploy<span style="color: #339933;">;</span>
worker_processes  <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#error_log   logs/error.log debug;
</span>
events <span style="color: #009900;">&#123;</span>
  worker_connections  <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
http <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">include</span>        conf<span style="color: #339933;">/</span>mime<span style="color: #339933;">.</span>types<span style="color: #339933;">;</span>
  default_type   application<span style="color: #339933;">/</span>octet<span style="color: #339933;">-</span>stream<span style="color: #339933;">;</span>
  sendfile        on<span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">#tcp_nopush     on;
</span>  keepalive_timeout  <span style="color: #cc66cc;">65</span><span style="color: #339933;">;</span>
  tcp_nodelay        on<span style="color: #339933;">;</span>
&nbsp;
  gzip  on<span style="color: #339933;">;</span>
  gzip_min_length  <span style="color: #cc66cc;">1100</span><span style="color: #339933;">;</span>
  gzip_buffers     <span style="color: #cc66cc;">4</span> 8k<span style="color: #339933;">;</span>
  gzip_types       text<span style="color: #339933;">/</span>plain<span style="color: #339933;">;</span>
&nbsp;
  upstream mongrel <span style="color: #009900;">&#123;</span>
    server 127<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>1<span style="color: #339933;">:</span><span style="color: #cc66cc;">3000</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  server <span style="color: #009900;">&#123;</span>
    listen       <span style="color: #cc66cc;">80</span><span style="color: #339933;">;</span>
    server_name  example<span style="color: #339933;">.</span>com<span style="color: #339933;">;</span>
    root         <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span>www<span style="color: #339933;">/</span>apps<span style="color: #339933;">/</span>example<span style="color: #339933;">/</span><span style="color: #990000;">current</span><span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">public</span><span style="color: #339933;">;</span>
    index        index<span style="color: #339933;">.</span>html index<span style="color: #339933;">.</span>htm<span style="color: #339933;">;</span>
&nbsp;
    try_files  <span style="color: #000088;">$uri</span><span style="color: #339933;">/</span>index<span style="color: #339933;">.</span>html <span style="color: #000088;">$uri</span><span style="color: #339933;">.</span>html <span style="color: #000088;">$uri</span> <span style="color: #339933;">@</span>mongrel<span style="color: #339933;">;</span>
&nbsp;
    location <span style="color: #339933;">@</span>mongrel <span style="color: #009900;">&#123;</span>
      proxy_set_header  X<span style="color: #339933;">-</span>Real<span style="color: #339933;">-</span>IP        <span style="color: #000088;">$remote_addr</span><span style="color: #339933;">;</span>
      proxy_set_header  X<span style="color: #339933;">-</span>Forwarded<span style="color: #339933;">-</span><span style="color: #b1b100;">For</span>  <span style="color: #000088;">$proxy_add_x</span>
_forwarded_for<span style="color: #339933;">;</span>
      proxy_set_header  Host             <span style="color: #000088;">$http_host</span><span style="color: #339933;">;</span>
      proxy_redirect    off<span style="color: #339933;">;</span>
      proxy_pass        http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//mongrel;</span>
    <span style="color: #009900;">&#125;</span>
    error_page   <span style="color: #cc66cc;">500</span> <span style="color: #cc66cc;">502</span> <span style="color: #cc66cc;">503</span> <span style="color: #cc66cc;">504</span>  <span style="color: #339933;">/</span>50x<span style="color: #339933;">.</span>html<span style="color: #339933;">;</span>
    location <span style="color: #339933;">=</span> <span style="color: #339933;">/</span>50x<span style="color: #339933;">.</span>html <span style="color: #009900;">&#123;</span>
      root   html<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Подробнее о конфиге написано на <a rel="nofollow" href="http://wiki.nginx.org/RubyonRailsMongrel" target="_blank">официальной вики-странице Nginx&#8217;а</a>.</p>
<h2>запуск</h2>
<p>Сначала запускаем Mongrel:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">$ cd <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span>www<span style="color: #339933;">/</span>apps<span style="color: #339933;">/</span>example<span style="color: #339933;">/</span><span style="color: #990000;">current</span><span style="color: #339933;">/</span>
$ rails s <span style="color: #339933;">-</span>e production
<span style="color: #339933;">=&gt;</span> Booting Mongrel
<span style="color: #339933;">=&gt;</span> Rails 3<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>10 application starting in production
on http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//0.0.0.0:3000</span>
<span style="color: #339933;">=&gt;</span> Call with <span style="color: #339933;">-</span>d to detach
<span style="color: #339933;">=&gt;</span> Ctrl<span style="color: #339933;">-</span>C to shutdown server</pre></td></tr></table></div>

<p>Запустить Mongrel как демон можно так:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">$ rails s <span style="color: #339933;">-</span>e production <span style="color: #339933;">-</span>d</pre></td></tr></table></div>

<p>И теперь запускаем Nginx, у меня, например, это выглядит так:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /opt/nginx/sbin/nginx</span></pre></td></tr></table></div>

<p>Типа все, но надо не забыть запретить открытию порта Mogrel&#8217;а (здесь 3000) из внешки.<br />
<meta property="og:image" content="http://blog.lukmus.ru/wp-content/uploads/2011/10/commie-obama.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lukmus.ru/2011/10/31/rails-3-na-nginxmongrel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
