最終更新:
clever_next 2012年02月06日(月) 04:08:11履歴
MongrelっていうのはWEBrick互換のサーバプログラムらしい。
Apache をリバースプロキシとして動作させ、Rails アプリケーションへのリクエストを Mongrel にプロキシする。
まずはそれぞれのバージョン
Apache をリバースプロキシとして動作させ、Rails アプリケーションへのリクエストを Mongrel にプロキシする。
まずはそれぞれのバージョン
- Apache 2.2.17
- ruby 1.8.7 (2011-12-28 patchlevel 357) [i386-mingw32]
- Rails 2.3.14
- mongrel (1.1.5 x86-mingw32)
1.mongrel_serviceのインストール
2.mongrelの起動確認
mongrelをインストールすると勝手に切り替わるようだ。
こちらで起動した方が
3.Apacheの設定
リバースプロキシとして設定するので
httpd.conf
今回はVirtualHostを使っているのでhttpd-vhost.confに以下を設定。
httpd-vhost.conf
これで本来Mongrelにhttp://localhost:3000/でアクセスしてたのをhttp://ruby.localhost/でアクセスできるようになった。
ブサイクなポート指定をわざわざしなくてOKになった。
F:\dev\ruby\workspace\practice>gem install mongrel_service Successfully installed gem_plugin-0.2.3 Successfully installed cgi_multipart_eof_fix-2.5.0 Successfully installed mongrel-1.1.5-x86-mingw32 Successfully installed mongrel_service-0.4.0 4 gems installed Installing ri documentation for gem_plugin-0.2.3... Installing ri documentation for cgi_multipart_eof_fix-2.5.0... Installing ri documentation for mongrel-1.1.5-x86-mingw32... Installing ri documentation for mongrel_service-0.4.0... Installing RDoc documentation for gem_plugin-0.2.3... Installing RDoc documentation for cgi_multipart_eof_fix-2.5.0... Installing RDoc documentation for mongrel-1.1.5-x86-mingw32... Installing RDoc documentation for mongrel_service-0.4.0...
2.mongrelの起動確認
F:\dev\ruby\workspace\practice>mongrel_rails start ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. INT => stop (no restart). ** Mongrel 1.1.5 available at 0.0.0.0:3000 ** Use CTRL-C to stop.ちなみにWEBrickを起動させるときのように
ruby script/serverでも起動できる。
mongrelをインストールすると勝手に切り替わるようだ。
こちらで起動した方が
- リダイレクトがされない。
- 詳細画面でエラーになる。
- Content-Type text/plainになってしまう。
- レスポンスが返ってこない場合ある。
3.Apacheの設定
リバースプロキシとして設定するので
httpd.conf
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.soこれらがコメントされていたら外す。
今回はVirtualHostを使っているのでhttpd-vhost.confに以下を設定。
httpd-vhost.conf
<VirtualHost *:80> ServerAdmin practice@ruby.localhost DocumentRoot "F:\dev\ruby\workspace\practice\public" ServerName ruby.localhost ServerAlias www.ruby.localhost ##ErrorLog "logs/dummy-host2.localhost-error.log" ##CustomLog "logs/dummy-host2.localhost-access.log" combined <IfModule mod_proxy.c> <Proxy *> Order deny,allow allow from all </Proxy> ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </IfModule> </VirtualHost>Apacheの再起動。
これで本来Mongrelにhttp://localhost:3000/でアクセスしてたのをhttp://ruby.localhost/でアクセスできるようになった。
ブサイクなポート指定をわざわざしなくてOKになった。
タグ
このページへのコメント
uGfcGS <a href="http://dcrjedmikidh.com/">dcrjedmikidh</a>, [url=http://hmxfiqlhbqxa.com/]hmxfiqlhbqxa[/url], [link=http://qqoawocthqxv.com/]qqoawocthqxv[/link], http://ouaxxkctqcdr.com/