使用Apache和Mongrel部署Ruby on Rails

时间:2020-11-28 20:44:17

I'm fairly new to ruby on rails and web development. Here is my setup which I followed from this link http://tonyrose023.blogspot.com/2007/01/multiple-rails-apps-with-mongrel.html I run multiple rails applications on Apache2 with Mongrel clusters.

我对rails和web开发上的ruby相当新。以下是我在此链接中的设置http://tonyrose023.blogspot.com/2007/01/multiple-rails-apps-with-mongrel.html我在Apache2上使用Mongrel群集运行多个rails应用程序。

http://services.abc.edu/app1 http://services.abc.edu/app2 http://services.abc.edu/app3

http://services.abc.edu/app1 http://services.abc.edu/app2 http://services.abc.edu/app3

This is what my 'virtual host' (/etc/apache2/sites-availabe/services.abc.edu) file looks like

这就是我的'虚拟主机'(/etc/apache2/sites-availabe/services.abc.edu)文件的样子

--------------
<Proxy balancer://app1> 
BalancerMember http://services.abc.edu:8000 
BalancerMember http://services.abc.edu:8001 
BalancerMember http://services.abc.edu:8002
Order deny,allow
Deny from all
Allow from all
</Proxy>

<Proxy balancer://app2>
BalancerMember http://services.abc.edu:8004
BalancerMember http://services.abc.edu:8005
Order deny,allow
Deny from all
Allow from all
</Proxy>

<Proxy balancer://app3>
BalancerMember http://services.abc.edu:8006
BalancerMember http://services.abc.edu:8007
Order deny,allow
Deny from all
Allow from all
</Proxy>



<VirtualHost *:80>
    ServerName services.abc.edu
    DocumentRoot /home/joe/projects/app1/public


<Directory "/home/joe/projects/app1/public"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 

<Directory "/home/joe/projects/app2/public"> 
Options FollowSymLinks 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 

<Directory "/home/joe/projects/app3/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

RewriteEngine On 


# Rewrite index to check for static 
#RewriteRule ^/$ /index.html [QSA] 
# Rewrite to check for Rails cached page 
RewriteRule ^([^.]+)$ $1.html [QSA] 
# Redirect all non-static requests to cluster 
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f 
#RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L] 

RewriteRule ^/app1(.*)$ balancer://app1%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/app2(.*)$ balancer://app2%{REQUEST_URI} [P,QSA,L]
RewriteRule ^/app3(.*)$ balancer://app3%{REQUEST_URI} [P,QSA,L]

</VirtualHost>
-----------------------------------------

My questions are

我的问题是

1) If anybody can comment on my setup and offer any suggestions would be great.

1)如果有人可以评论我的设置并提供任何建议将是伟大的。

2) As you can see I have one DocumentRoot, although right now all the 3 apps work since they use same images but I think in the future I need to have DocumentRoot for each app

2)正如你所看到我有一个DocumentRoot,虽然现在所有3个应用程序都工作,因为他们使用相同的图像但我认为将来我需要为每个应用程序使用DocumentRoot

3) I need to get the apps running securely so I need to make this run with SSL (port 443) and I need some help with making it run with SSL. Any pointers would be helpful since I never installed a cert. I created the csr and the key and I have the cert with me. I'm researching on what are the next steps.

3)我需要安全地运行应用程序,所以我需要使用SSL(端口443)运行这个程序,我需要一些帮助,使它运行SSL。任何指针都会有所帮助,因为我从未安装过证书。我创建了csr和密钥,我有证书。我正在研究接下来的步骤。

Thanks!

1 个解决方案

#1


I would advise you to look into Passenger. It's really easy to set up, lets Rails apps share memory, removes the burden of managing a cluster of mongrels and requires virtually no configuration. All you need are a special 'config.ru' file with a RackUp config and a DocumentRoot pointing to RAILS_ROOT/public set in Apache.

我建议你调查乘客。设置起来非常简单,让Rails应用程序共享内存,消除管理一组mongrel的负担,几乎不需要任何配置。您只需要一个特殊的'config.ru'文件,其中包含RackUp配置和指向Apache中RAILS_ROOT / public set的DocumentRoot。

The problem with running multiple apps in mongrel is that you need a seperate mongrel instance for each of them.

在mongrel中运行多个应用程序的问题是,每个应用程序都需要一个单独的mongrel实例。

As for your SSL question, I have found it really easy to set up SSL for some parts of my sites in Nginx. I don't remember how to do it in Apache, but there are most likely some good howtos out there.

至于您的SSL问题,我发现在Nginx中为我的网站的某些部分设置SSL非常容易。我不记得在Apache中如何做到这一点,但最有可能是一些好的howtos。

#1


I would advise you to look into Passenger. It's really easy to set up, lets Rails apps share memory, removes the burden of managing a cluster of mongrels and requires virtually no configuration. All you need are a special 'config.ru' file with a RackUp config and a DocumentRoot pointing to RAILS_ROOT/public set in Apache.

我建议你调查乘客。设置起来非常简单,让Rails应用程序共享内存,消除管理一组mongrel的负担,几乎不需要任何配置。您只需要一个特殊的'config.ru'文件,其中包含RackUp配置和指向Apache中RAILS_ROOT / public set的DocumentRoot。

The problem with running multiple apps in mongrel is that you need a seperate mongrel instance for each of them.

在mongrel中运行多个应用程序的问题是,每个应用程序都需要一个单独的mongrel实例。

As for your SSL question, I have found it really easy to set up SSL for some parts of my sites in Nginx. I don't remember how to do it in Apache, but there are most likely some good howtos out there.

至于您的SSL问题,我发现在Nginx中为我的网站的某些部分设置SSL非常容易。我不记得在Apache中如何做到这一点,但最有可能是一些好的howtos。

相关文章