# PHP app on the same server as Rails app

**URL:** <https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313>\
**Category:** Rails\
**Created:** [September 29, 2009, 1:13am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313 "2009-09-29T01:13:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 1:13am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/1 "2009-09-29T01:13:44Z")

</div>

Hi,

I am trying to figure out how to best serve a PHP app on the same server  
as my Rails app. Basically, the PHP app is a 3rd party blog that I want  
to be able to access on the same server. The server is powered by  
mongrel cluster and apache. I tried putting the blog in /public but then  
/blog/login does not work, while /blog/login.php does. Anyway what is  
the best way to solve this?

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 1:22am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/2 "2009-09-29T01:22:36Z")

</div>

On Mon, Sep 28, 2009 at 6:13 PM, Greg L.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am trying to figure out how to best serve a PHP app on the same server  
> as my Rails app. Basically, the PHP app is a 3rd party blog that I want  
> to be able to access on the same server. The server is powered by  
> mongrel cluster and apache. I tried putting the blog in /public but then  
> /blog/login does not work, while /blog/login.php does. Anyway what is  
> the best way to solve this?

I’d set each app up on it’s own subdomain. But if you can’t you can  
use mod\_rewrite to sort out where requests should go.

[http://httpd.apache.org/docs/2.2/mod/mod\_rewrite.html](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html)

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 1:35am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/3 "2009-09-29T01:35:38Z")

</div>

Greg D. wrote:

> On Mon, Sep 28, 2009 at 6:13 PM, Greg L.  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I am trying to figure out how to best serve a PHP app on the same server  
> > as my Rails app. Basically, the PHP app is a 3rd party blog that I want  
> > to be able to access on the same server. The server is powered by  
> > mongrel cluster and apache. I tried putting the blog in /public but then  
> > /blog/login does not work, while /blog/login.php does. Anyway what is  
> > the best way to solve this?
> 
> I’d set each app up on it’s own subdomain. But if you can’t you can  
> use mod\_rewrite to sort out where requests should go.
> 
> [mod\_rewrite - Apache HTTP Server Version 2.2](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html)
> 
> –  
> Greg D.  
> [http://destiney.com/](http://destiney.com/)

I agree that subdomain would be great. However when I set up  
[blog.mysite.com](http://blog.mysite.com) all of the links still point to [mysite.com/blog](http://mysite.com/blog) instead  
of [blog.mysite.com/blog](http://blog.mysite.com/blog). Is it because I set up the subdomain wrong or  
is it because mongrel is doing something here?

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 1:58am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/4 "2009-09-29T01:58:19Z")

</div>

I would assume that you are using passenger…

Just setup the rails app like normal then create a locations element  
for the blog and turn off rails for this directory

And here is the cut’n paste from the Passenger documentation

\<VirtualHost \*:80\>  
ServerName [www.foo.com](http://www.foo.com)  
DocumentRoot /apps/foo/public  
\<Directory /apps/foo/public/wordpress\>  
PassengerEnabled off  
AllowOverride all # ← Makes Wordpress’s .htaccess file  
work.

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 3:03am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/5 "2009-09-29T03:03:53Z")

</div>

Greg L. wrote:

> Hi,
> 
> I am trying to figure out how to best serve a PHP app on the same server  
> as my Rails app. Basically, the PHP app is a 3rd party blog that I want  
> to be able to access on the same server. The server is powered by  
> mongrel cluster and apache. I tried putting the blog in /public but then  
> /blog/login does not work, while /blog/login.php does. Anyway what is  
> the best way to solve this?

I personally just use a different sub-domain.

Cheers,  
Mohit.  
9/29/2009 | 9:02 AM.

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 3:38am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/6 "2009-09-29T03:38:20Z")

</div>

> I agree that subdomain would be great. However when I set up  
> [blog.mysite.com](http://blog.mysite.com) all of the links still point to [mysite.com/blog](http://mysite.com/blog) instead  
> of [blog.mysite.com/blog](http://blog.mysite.com/blog). Is it because I set up the subdomain wrong or  
> is it because mongrel is doing something here?

If you are using WP (but I think is the same for most blogging platform)  
you need to reinstall the blog engine , you cannot just move from one  
address to another

In WP there is a way to change the base blog\_url but is easier and safer  
to just export , reinstall and import.

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 6:09pm UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/7 "2009-09-29T18:09:05Z")

</div>

[http://kb.mediatemple.net/questions/279/Ruby+on+Rails+using+Mongrel+Clusters](http://kb.mediatemple.net/questions/279/Ruby+on+Rails+using+Mongrel+Clusters)

It looks like there’s a part about setting up your vhost.conf. Did you  
go through these steps? If so, I’d guess that it’s the place you want  
to make your edits to exclude blog URL from being redirected.

On Sep 28, 8:37 pm, Greg L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 5:37am UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/8 "2009-09-29T05:37:44Z")

</div>

heimdull wrote:

> I would assume that you are using passenger…
> 
> Just setup the rails app like normal then create a locations element  
> for the blog and turn off rails for this directory
> 
> And here is the cut’n paste from the Passenger documentation
> 
> \<VirtualHost \*:80\>  
> ServerName [www.foo.com](http://www.foo.com)  
> DocumentRoot /apps/foo/public  
> \<Directory /apps/foo/public/wordpress\>  
> PassengerEnabled off  
> AllowOverride all # ← Makes Wordpress’s .htaccess file  
> work.

I’m using mongrel cluster behind Apache. It is a WP blog. I’m on  
MediaTemple host and the way they set it up there is no DocumentRoot  
specified in httpd.conf. Is there anyway to tell Apache not to send the  
request to mongrel (like PassengerEnabled)?

---

<div class="post-metadata">

**Author:** ![russianbandit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e36b37/32.png) [@russianbandit](https://www.ruby-forum.com/u/russianbandit)\
**Post date:** [September 29, 2009, 9:37pm UTC](https://www.ruby-forum.com/t/php-app-on-the-same-server-as-rails-app/176313/9 "2009-09-29T21:37:57Z")

</div>

Thanks to everyone for the help.

Indeed my problem was that I needed to re-install the WP blog like  
Simone suggested. Now my subdomain works as expected.
