?
Solved

How to deploy Rails App and PHP App in same box

Posted on 2009-04-15
14
Medium Priority
?
510 Views
Last Modified: 2013-12-12
Recently I worked on some rails projects. Now I want to deploy one of my project in sandbox (Ubuntu Server 8.10)  in production mode. The problem is sandbox already have some APP made in PHP. So, is there any way that I can run both PHP and Rails app in same box with Phusion Passenger installed.

Like if I go to http://sandbox/  <------ takes to PHP part

If I go to http://sandbox/rails <------ takes to Rails App
0
Comment
Question by:nicholasnet
  • 4
  • 4
  • 3
11 Comments
 
LVL 14

Accepted Solution

by:
wesgarrison earned 500 total points
ID: 24153919
Presuming you're running Apache, I'd suggest you create a virtual host instead of running from a subdirectory.  Something like:
http://rails-app.sandbox.com

Here's a tutorial for setting up Passenger on a virtual host on Ubuntu:
http://www.aeonscope.net/2009/03/15/phusion-passenger-on-ubuntu/

0
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 24156614
I agree with Wes..

If you run them as a separate virtual host, you can run as many as you like, I have a server with Passenger setup running about 5 rails sites, works like a dream.
0
 
LVL 1

Author Comment

by:nicholasnet
ID: 24157832
Can you please tell me doades how you do that. I want to run my PHP app as well. I know I can do with virtual host but it did not worked it gave me error 500.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:wesgarrison
ID: 24158780
Did you check out the tutorial above?  It tells you how to configure virtual hosts.  You configure the PHP one in the same way, but Apache will use mod_php for the php files.  It's smart like that.

If you're having issues, copy your virtual host configuration lines in as a code snippet for us to check out.
0
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 24159312
If you follow the tutorial that wes posted first, this should get you working, I have tested this on a new ubuntu VM and it worked very well.

Andrew
0
 
LVL 1

Author Comment

by:nicholasnet
ID: 24167774
Here is the problem I am having. I can access only one at a time. Either PHP or Rails but not both.


Here is my vhost for PHP
---------------------------------------------
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/nirmal/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/nirmal/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

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

Vhost for SSL
-----------------------------------------------------------------------------------
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        SSLEngine On
        SSLCertificateFile /etc/apache2/ssl/apache.pem

        DocumentRoot /home/nirmal/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/nirmal/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

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

VHOST for Rails
-----------------------------------------------------------------------------------------------------------
<VirtualHost *:80>
        ServerName imtecintranet
        ServerAlias imtecintranet
        DocumentRoot /home/nirmal/www/wishlist/public
</VirtualHost>
0
 
LVL 10

Assisted Solution

by:Andrew Doades
Andrew Doades earned 500 total points
ID: 24170660
I have mine setup in the same 'style' I have just one file in sites-available, with this in, this is my php/html website and my ruby on rails application

<VirtualHost *:80>
DocumentRoot /home/user/www/data
ServerName www.domain.com

   ErrorLog "/var/log/main-error_log"
   CustomLog "/var/log/main-access_log" common

   <Directory "/home/user/www/data">
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
   </Directory>
DirectoryIndex index.php

</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/home/user/rails1/public"
    ServerName rails1.domain.com

   ErrorLog "/var/log/rails1-error_log"
   CustomLog "/var/log/rails1-access_log" common

   <Directory "/home/user/rails1/public">
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>

Maybe try coping my stuff, but with your site details and see if it works?
0
 
LVL 1

Author Comment

by:nicholasnet
ID: 24171988
I cannot have servername like railsap.testbox.com

I can only have one servername like testbox

However like if I type http://testbox  -> this should fire PHP
and if I type http://testbox/app -> this should fire rails app

Can I do this
0
 
LVL 10

Expert Comment

by:Andrew Doades
ID: 24172228
I sadly have never used the setup like that, where the rails app is an alias from the main site using passenger... Wes, have you any experience with this type of thing?
I have only setup sites with subdomains not as aliases
0
 
LVL 14

Expert Comment

by:wesgarrison
ID: 26905110
I think both doades and I answered the question. Virtual hosting through subdomain or subdirectory allows both Rails and PHP to be served by Apache.
0
 
LVL 14

Expert Comment

by:wesgarrison
ID: 27176844
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question