nicholasnet
asked on
How to deploy Rails App and PHP App in same box
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
Like if I go to http://sandbox/ <------ takes to PHP part
If I go to http://sandbox/rails <------ takes to Rails App
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
If you're having issues, copy your virtual host configuration lines in as a code snippet for us to check out.
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
Andrew
ASKER
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.lo g 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.pe m
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.lo g 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>
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.lo
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.pe
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.lo
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/
</VirtualHost>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
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
I have only setup sites with subdomains not as aliases
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.
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.