サーバの設定について

1,186 views
Skip to first unread message

島村

unread,
Aug 31, 2009, 7:34:56 AM8/31/09
to rbc-incubator
島村@太宰府市です

レンタルサーバ上で Rails アプリを動かそうとしているのですが、行き詰っています。

サーバは借り上げで root 権限があります。
ここで既に別の Rails アプリが稼働中です。これに追加でデプロイを試みています。

稼働中 example.com
追加したい example.com/app1

passenger が動いているので google であれこれ調べているのですが、なかなか解決できません。
多分、目の付けどころが間違っていると思うのですが…

参考にしているサイト
http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_ruby_on_rails_application
ここの3.2. Deploying to a sub URI なんかを見ています。

もしかして passenger が動いてない? なんて。どうやったら確認できるでしょうか。
まとまり無いですが、なにかアドバイスをお願いします。

ruby 1.8.7
rails 2.3.3
CentOS

以上、よろしくお願いします。

田代勝也

unread,
Aug 31, 2009, 11:57:42 AM8/31/09
to rbc-in...@googlegroups.com
田代@筑紫野市です。

> 稼働中 example.com
> 追加したい example.com/app1
>
> passenger が動いているので google であれこれ調べているのですが、なかなか解決できません。
> 多分、目の付けどころが間違っていると思うのですが…
>
> 参考にしているサイト
> http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_ruby_on_rails_application
> ここの3.2. Deploying to a sub URI なんかを見ています。
>
> もしかして passenger が動いてない? なんて。どうやったら確認できるでしょうか。
> まとまり無いですが、なにかアドバイスをお願いします。
>
> ruby 1.8.7
> rails 2.3.3
> CentOS

稼働中の(example.com)はPassengerで動いていて、
そのサブディレクトリに別のRailsプロジェクトを入れて動かそうとしているのでしょうか?

Passengerの動作状況の確認ですが、passenger-status や passenger-memory-statsなどのコマンドで確認できるかと。

# passenger-status
----------- General information -----------
max = 6
count = 2
active = 0
inactive = 2
Using global queue: no
Waiting on global queue: 0

----------- Applications -----------
/home/tashiro/rails/app1:
PID: 7938 Sessions: 0

/home/tashiro/rails/photo:
PID: 7943 Sessions: 0


複数のRailsアプリを動かそうとする場合ですが、例えば以下のように同じレベルのディレクトリに並べる方が自然な気はするのですがどうでしょうか?

********** /etc/httpd/conf/httpd.conf **********
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.example.com
RailsBaseURI /app1
RailsBaseURI /app2
RailsBaseURI /app3
</VirtualHost>
********** /etc/httpd/conf/httpd.conf **********

$ ls -al /var/www/html
drwxr-xr-x 2 root root 4096 2009-02-01 23:24 ./
drwxrwxr-x 8 root syslabo 4096 2009-07-17 09:42 ../
lrwxrwxrwx 1 root root 37 2009-02-01 22:59 app1 -> /rails_app/app1/public/
lrwxrwxrwx 1 root root 33 2009-02-01 22:59 app2 -> /rails_app/app2public/
lrwxrwxrwx 1 root root 32 2009-02-01 23:24 app3 -> /rails_app/app3/public/

koichi shimamura

unread,
Aug 31, 2009, 7:50:04 PM8/31/09
to rbc-in...@googlegroups.com
島村@太宰府市です

[root@server01 ~]# passenger-status
*** Cleaning stale folder /tmp/passenger.19456
*** Cleaning stale folder /tmp/passenger.19753
延々と続いて
*** Cleaning stale folder /tmp/passenger.19038
*** ERROR: Cannot query status for Passenger instance 19806:
No such file or directory - /tmp/passenger.19806/info/status.socket
[root@server01 ~]#

となってしまいました。動いてないってことでしょうか??

/etc/httpd/conf/httpd.conf は、以下のようになっています。

<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/rails_app/app0/public/
ServerAlias www.example.com
ProxyRequests On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / balancer://mycluster/
ProxyPassReverse / balancer://mycluster/
<Proxy balancer://mycluster>
BalancerMember http://localhost:3000 loadfactor=10 keepalive=On
</Proxy>
</VirtualHost>

<VirtualHost *:80>         <-ここからが今回追加した分
ServerName example.com
DocumentRoot /var/www/html
RailsBaseURI /app1
</VirtualHost>

あと、気になっているのが apache を再起動したときに
[warn] module passenger_module is already loaded, skipping
が、表示されます。

まず、以下を確かめないといけないかなと。
(1)もとからあった app0 は本当に passenger で動いていたのか。

ああ、、、分からないことだらけです・・・


2009年9月1日0:57 田代勝也 <katsuya...@gmail.com>:

田代勝也

unread,
Sep 2, 2009, 8:52:24 AM9/2/09
to rbc-in...@googlegroups.com
田代@筑紫野市です。

> /etc/httpd/conf/httpd.conf は、以下のようになっています。
>
> <VirtualHost *:80>
> ServerName example.com
> DocumentRoot /var/www/rails_app/app0/public/
> ServerAlias www.example.com
> ProxyRequests On
> <Proxy *>
> Order deny,allow
> Allow from all
> </Proxy>
> ProxyPass / balancer://mycluster/
> ProxyPassReverse / balancer://mycluster/
> <Proxy balancer://mycluster>
> BalancerMember http://localhost:3000 loadfactor=10 keepalive=On
> </Proxy>
> </VirtualHost>

まずこちらの設定ですが、PassengerではなくMongrel Cluster + Apache(ReverseProxy)構成の設定ではないでしょうか?
おそらくMongrelがlocalhost:3000でListenしている状態になっていると思います。

ということで、以下の点については、app0はPassengerではなくてMongrelで動いていたということだと思います。


> まず、以下を確かめないといけないかなと。
> (1)もとからあった app0 は本当に passenger で動いていたのか。

>


> <VirtualHost *:80>         <-ここからが今回追加した分
> ServerName example.com
> DocumentRoot /var/www/html
> RailsBaseURI /app1
> </VirtualHost>

次にこちらですが、同じexample.comでVirtualHostが更に追加されているので、何かおかしい気がします。(こんなこと出来ましたっけ?)
Passengerを使う設定としては、Passengerのインストールがうまく行っていれば良さそうですが。

可能でしたら、一度上記のMongrel+Apacheの設定をコメントアウトして、Passengerだけの設定でトライしてみてはいかがでしょうか?

>
> あと、気になっているのが apache を再起動したときに
> [warn] module passenger_module is already loaded, skipping
> が、表示されます。

こちらについては、以下のような設定行が、Apacheの設定ファイルに2回記述されているからだと思います。(Includeされているものも含めて)

LoadModule passenger_module mod_passenger.soのパス

Akiyoshi Sakaguchi

unread,
Sep 4, 2009, 8:40:05 AM9/4/09
to rbc-in...@googlegroups.com
さかぐちです。

>> <VirtualHost *:80>         <-ここからが今回追加した分
>> ServerName example.com
>> DocumentRoot /var/www/html
>> RailsBaseURI /app1
>> </VirtualHost>
>
> 次にこちらですが、同じexample.comでVirtualHostが更に追加されているので、何かおかしい気がします。(こんなこと出来ましたっけ?)
> Passengerを使う設定としては、Passengerのインストールがうまく行っていれば良さそうですが。

これは、私もおかしい気がします。

私のところでは、以下のような感じで、1 つの example.com の VirtualHost 内
で定義して使っています。

<VirtualHost *:80>
ServerName example.com

DocumentRoot /var/www/html

RailsBaseURI /hoge
RailsBaseURI /fuga

...
</VirtualHost>

ただし、デプロイの都合上、hoge および fuga のアプリは、別ディレクトリに
展開しています。それらを /var/www/html/hoge および /var/www/html/fuga に
スタティックリンクしています。

この定義で、お望みのような環境が構築できています。

メインの Rails アプリ: http://example.com/
追加の Rails アプリ: http://example.com/hoge
http://example.com/fuga

ご参考まで。

--
麻生情報ビジネス専門学校
教務部
坂口 昭吉(さかぐち あきよし)
tel:092-415-2291 / fax:092-415-2297

Reply all
Reply to author
Forward
0 new messages