Run two different Rails application on one dedicated server

半城伤御伤魂 提交于 2019-12-03 03:54:42

问题


I have one dedicated server with below configurations

i3 - Dual Core - 3.06Ghz H/T
16GB RAM
500GB SATA2

Now I want to execute two different Rails application on one dedicated server. A both application are different but they are using common database.

Is it possible to do that? If yes – How can I do that? Is Phusion Passenger with Apache a good approach? If yes - How can I configure two application with one Phusion Passenger server?


回答1:


I will describe how I run multiple Rails applications on one Linux server, using Apache, Phusion Passenger, and some version of Ruby. You have many choices, but this should help you get started. Many of these details come from the installation script

First, install Phusion Passenger.

> gem install passenger

Second, build the Apache 2 Passenger module. You should be able to execute the following script installed during step one.

> passenger-install-apache2-module

This script will compile the Apache 2 module and explain how to configure Apache. If dependencies are missing the script should offer some helpful advice about how to install them.

Third, edit your Apache configuration file. I have to add something like this. (Just use this for references and don't worry about .rvm) The script run in step two will give you something that you can copy and paste.

LoadModule passenger_module /Users/me/.rvm/gems/ree/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
PassengerRoot /Users/me/.rvm/gems/ree/gems/passenger-3.0.9
PassengerRuby /Users/me/.rvm/wrappers/ree/ruby

Fourth, add something like this to your Apache configuration file for each application you want to run.

<VirtualHost *:80>
  ServerName app1.example.com
  DocumentRoot /somewhere/app1/public    # <-- be sure to point to 'public'!
  <Directory /somewhere/app1/public>
     AllowOverride all              # <-- relax Apache security settings
     Options -MultiViews            # <-- MultiViews must be turned off
  </Directory>
</VirtualHost>

If you have two Rails application sharing one database then they will both have similar connection information in config/database.yml




回答2:


Yes, It's definitely possible. I've never done it with Passenger + Apache, but I'm sure thats a fine way. I've only ever done it with thin + nginx.




回答3:


Passenger Phusion with Apache is a solid approach. The fact that they are using the same database shouldn't be a problem (just make sure they don't step on each other in any way).

Generally, just set things up as normal, but take a look at Apache name-based virtual hosts:

http://httpd.apache.org/docs/2.2/vhosts/name-based.html



来源:https://stackoverflow.com/questions/7490189/run-two-different-rails-application-on-one-dedicated-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!