Running Rails applications with Passenger alongsid

2020-06-19 18:11发布

问题:

I'm setting a server where I will need to run Ruby On Rails 3 applications along with some PHP websites. The server is a CentOS 5.8 machine running Apache 2.4.3. The server is for testing and PRE-production, so performance is not an issue.

I'm using Phusion Passenger for the Rails apps, and I've created a bunch of virtual-hosts (with associated folders and DB accounts). Then, I'm planning to use other v-hosts for PHP.

Is it possible? How should I proceed?

Thank you very much


details:
httpd.conf:

LoadModule passenger_module /app/auser/.rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17/ext/apache2/mod_passenger.so  
PassengerRoot /app/auser/.rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.17  
PassengerRuby /app/auser/.rvm/wrappers/ruby-1.9.3-p286/ruby  

(...)

##
## Virtual hosts
Include conf/extra/httpd-vhosts-phpmyadmin.conf
Include conf/extra/httpd-vhosts-rails01.conf
Include conf/extra/httpd-vhosts-rails02.conf
Include conf/extra/httpd-vhosts-php01.conf
Include conf/extra/httpd-vhosts-php02.conf
....

Passenger-managed v-hosts will be like:
Include conf/extra/httpd-vhosts-rails01.conf

<VirtualHost *:80>
   ServerName rails01.lcl
   DocumentRoot "/app/auser/apps/rails01/public"
   <Directory "/app/auser/apps/rails01/public">
      AllowOverride all
      Options -MultiViews
   </Directory>
</VirtualHost>

PHP-based v-hosts will be like: Include conf/extra/httpd-vhosts-php01.conf

<VirtualHost *:80>
    ServerName php01.lcl
    DocumentRoot "/app/auser/apps/php01/public"
    <Directory "/app/auser/apps/php01/public">
        Options FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

回答1:

Yes, Running Rack/Rails alongside PHP definitely works.



回答2:

There is a really cool gem called rack-legacy which might be what you are are looking for. It allows you to execute PHP code hosted on your Rails application server through php-cgi.

Rack Legacy tries to provide interaction with legacy environments like PHP and CGI while still getting the Rack portability so you don't need a full Apache/lighttpd stack.

I have used for some experiments, and it seems is possible to have a wordpress running and served with the Rails app server without having to mess up with apache/ngix files.