使用 Apache 和 Mongrel 部署 Ruby on Rails

发布于 2024-07-13 11:00:02 字数 2768 浏览 4 评论 0原文

我对 ruby​​ on Rails 和 Web 开发相当陌生。 这是我从这个链接 http: //tonyrose023.blogspot.com/2007/01/multiple-rails-apps-with-mongrel.html 我使用 Mongrel 集群在 Apache2 上运行多个 Rails 应用程序。

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

这是我的“虚拟主机”(/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>
-----------------------------------------

我的问题是

1)如果有人可以对我的设置发表评论并提供任何建议,那就太好了。

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

3) 我需要让应用程序安全运行,所以我需要使用 SSL(端口 443)运行它,并且我需要一些帮助来使其使用 SSL 运行。 任何指示都会有帮助,因为我从未安装过证书。 我创建了 csr 和密钥,并且随身携带了证书。 我正在研究下一步是什么。

谢谢!

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.

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

--------------
<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.

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

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.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你穿错了嫁妆 2024-07-20 11:00:04

我建议您查看Passenger。 它非常容易设置,让 Rails 应用程序共享内存,消除了管理杂种集群的负担,并且几乎不需要任何配置。 您所需要的只是一个特殊的“config.ru”文件,其中包含 RackUp 配置 和指向 Apache 中 RAILS_ROOT/public 集的 DocumentRoot。

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

至于您的 SSL 问题,我发现在 Nginx 中为我的网站的某些部分设置 SSL 非常容易。 我不记得如何在 Apache 中执行此操作,但很可能有一些 那里有很好的方法

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.

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文