Mongrel HOWTO

  • e,—environment (:environment)

Configures your Rails environment to what you need.

* Default: development

If given (no options) then Mongrel will run in the background. No Win32.

* Default: false

  • p,—port (:port)

Port to bind to when listening for connections.

* Default: 3000

  • a,—address (:host)

Address to bind to when listening for connections.

* Default: 0.0.0.0 (every interface)

  • l,—log (:log_file)

Where to dump log messages in daemon mode. Use an absolute path. No Win32.

* Default: $PWD/log/mongrel.log

  • P,—pid (:pid_file)

Where to write the PID file so start and stop commands know the Process ID. Use absolute paths. No Win32.

* Default: $PWD/log/mongrel.pid

  • n,—num-procs (:num_processors)

Maximum number of concurrent processing threads before Mongrel starts denying connections and trying to kill old threads.

* Default: 1024

  • t,—timeout (:timeout)

Time to pause between accepting clients. Used as a throttle mechanism.

* Default: 0

A YAML file that maps from file extensions to MIME types for static files. It’s important that if you are using page caching or you have a different language setting—like UTF8—then you have to configure this. Read more below.

* Default: not set.

  • c,—chdir (:cwd)

Directory to change to prior to starting Mongrel. “cwd” means “change working directory”.

* Default: . (current directory)

  • r,—root (:docroot)

Document root where Mongrel should serve files from. If you are putting Mongrel under a different base URI, and you want it to serve files out of a different directory then you need to set this.

* Default: public

  • B,—debug (:debug)

Turns on a debugging mode which traces objects, threads, files request parameters, and logs accesses writing them to log/mongrel_debug. This option makes Mongrel very slow.

* Default: false

  • C,—config (NONE)

Specifies a configuration YAML file that sets options you’re reading about right now. Read “Command Line Settings” below for more information. Use absolute paths.

* Default: no default

  • S,—script (:config_script)

A special Ruby file that is run after Rails is configured to give you the ability to change the configuration with Ruby. This would be where you can load customer Mongrel handlers, extra libraries, or setup additional Ruby code. This option is fairly advanced so use with caution.

* Default: not set

  • G,—generate (NONE)

Takes whatever options you’ve set for Mongrel, and the current defaults, and then writes them to a YAML file suitable for use with the -C option.

* Default: not set

—prefix uri
A URI to mount your Rails application at rather than the default /. This URI is stripped off all requests by Rails (not Mongrel) so it cannot end in /.

* Default: not set

—user USER
Must have—group too. The user to change to right after creating the listening socket. Use this if you have to bind Mongrel to a low port like port 80, but don’t want Mongrel to run as root. Not useful in Windows.

* Default: not set

—group GROUP
Must have—user too. The group to change to right after creating the listening socket. Not userful in Windows.

* Default: not set

例:mongrel_rails start -p 80 -d -e production




http://mongrel.rubyforge.org/docs/howto.html

mongrel を port 3000 ではなく、port 80 で動かす。

1.mongrel を port 3000 ではなく、port 80 で動かす。
――――――――――――――――――――――――――――――――――――――――

まず、port 80 は apache が占領しているので、排除する。

chkconfig httpd off

[root@localhost conf.d]# chkconfig httpd off
[root@localhost conf.d]#


つぎに、mongrel を 80 で起動する。

mongrel_rails start -p 80 -d -e production

[root@localhost conf.d]# cd /srv/www/lighttpd/lr_portal/
[root@localhost lr_portal]# mongrel_rails start -p 80 -d -e production

!!! PID file log/mongrel.pid already exists. Mongrel could be running already. Check your log/mongrel.log for errors.

!!! Exiting with error. You must stop mongrel and clear the .pid before I'll attempt a start.

[root@localhost lr_portal]#


ぬおおお、エラーー!
Mongrel could be running already.

すでに、走ってるらしい。

では、まず、停止。

[root@localhost lr_portal]# mongrel_rails stop
Sending TERM to Mongrel at PID 9877...Done.
[root@localhost lr_portal]#

うむ停止。

[root@localhost lr_portal]# mongrel_rails start -p 80 -d -e production
[root@localhost lr_portal]#

お!動いた??

アクセスしてみる。

http://10.20.138.111/


あれ??エラーだ!!

正常に接続できませんでした


10.20.138.111 のサーバへの接続を確立できませんでした。


なんで??


port 80に何か・・・。
ファイヤーウォール??


あ、lighttpd・・・そういえば、
前、ポート80にした記憶がアル・・・。

[root@localhost lr_portal]# /etc/init.d/lighttpd stop
lighttpd を停止中: [ OK ]

さらに!

[root@localhost lr_portal]# chkconfig lighttpd off
[root@localhost lr_portal]#

これで、

[root@localhost lr_portal]# mongrel_rails start -p 80 -d -e production
[root@localhost lr_portal]#

アクセスしてみる。

http://10.20.138.111/

キタ━━━━(゚∀゚)━━━━ッ!!?

これで、ポート 80 で見れた!!