SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2000
    Location
    Washington, DC
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Running PHP and RoR on same domain

    Is it possible to run one part of a site using PHP (a forum) while using RoR for the content section of the site?
    Don Lair
    GetItCheap.com - Earn cash back online.


  2. #2
    SitePoint Zealot logitron's Avatar
    Join Date
    Feb 2006
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I actually played around with the notion not too long ago on the Apache2 Server on my laptop. There might be another alternative, but the only way that I figured out how to work with both PHP and RoR, was to install RoR on a different port (ie port 8080). Like I said, there might be other alternatives, but that's how I got them both working.

    Patrick Smith
    Patrick Smith
    PHP Programmer

  3. #3
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can just use Aliases in Apache. Let's assume your main app uses rails and the php forum is located in the forums directory somewhere:

    Code:
    <VirtualHost *:80>
        ServerName rails
        DocumentRoot /path/application/public/
        ErrorLog /path/application/log/apache.log
    
        Alias /forums /path/to/php/application/forums
    
        <Directory /path/application/public/>
          Options ExecCGI FollowSymLinks
          AddHandler cgi-script .cgi
          AllowOverride all
          Order allow,deny
          Allow from all
        </Directory>
    </VirtualHost>
    Thats all you should need to do it. This is assuming you're using Apache for your RoR app as well.
    Erh

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes you would have to use an alias for either PHP or rails because rails file structure is so complex (though not complicated to understand) that it requires its own home.
    Happy switcher to OS X running on a MacBook Pro.

    Zend Certified Engineer

  5. #5
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally I think the best way of doing this is to run the two systems on separate subdomains.

    For example, on a recent client site we had their main website (Rails-driven) running off of the www subdomain and their site forum (punBB) running off of the forum subdomain. This was much less hassle.

  6. #6
    SitePoint Zealot
    Join Date
    Aug 2000
    Location
    Washington, DC
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've managed to get this working as:

    www.domain.com is PHP
    www.domain.com/rails/ is rails

    Installing rails has been a major pain in the butt, but making it work with PHP was not. You need to install RoR and fastcgi (fcgi), then use a .htaccess is the ruby public directory to tell it to use fcgi. Other tutorials cover this at length so I won't expand on it here. The following is how you make PHP and RoR play together.

    Here's how it looks:
    /home/USER/public_html/ (normal web root)
    /home/USER/rails_app/public/ (rails web root)

    Then in public_html type:
    ln -s ../rails_app/public rails

    Now domain.com/rails/ is a rails directory and the rest of the site is the same as before.
    Don Lair
    GetItCheap.com - Earn cash back online.


  7. #7
    Mal Reynolds Mandibal's Avatar
    Join Date
    Aug 2003
    Location
    Columbus
    Posts
    718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Luke Redpath
    Personally I think the best way of doing this is to run the two systems on separate subdomains.

    For example, on a recent client site we had their main website (Rails-driven) running off of the www subdomain and their site forum (punBB) running off of the forum subdomain. This was much less hassle.
    Definitely less hassle. Although using Alias in Apache isn't usually a hassle. Using symbolic links isn't much of a hassle usually either. Seems we've found quite a few solutions to the original question.
    Erh

  8. #8
    SitePoint Zealot
    Join Date
    Aug 2000
    Location
    Washington, DC
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I very nearly just picked up some shared space from a RoR host for a subdomain. But then that felt like a waste since I have this site on a dedicated server and the RoR part is going to use the most bandwidth.
    Don Lair
    GetItCheap.com - Earn cash back online.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •