Ruby on Rails with fcgi and apache

Discussion in 'HOWTO-Related Questions' started by TechG1rl, Nov 22, 2007.

Thread Status:
Not open for further replies.
  1. TechG1rl

    TechG1rl New Member

    Hi all,

    I am hoping someone can help me figure this out..

    I followed Falkos howto here:
    http://www.howtoforge.com/ruby_on_rails_debian_etch_p2

    and installed Ruby on Rails on my Feisty Fawn Ubuntu.. the instructions were the same :) However, I also followed a Howtoforge article on how to get your apache webserver up and running on Feisty Fawn like 6 months ago... and I am using the webserver to host just a family and friends little website with pics of the family to share with the family.. on port 80.

    I set up the default virtual machine file: /etc/apache2/sites-available/default

    so that it has 2 virtual machines listed, my original family site on port 80, and the ruby on rails application to run off port 1080.

    I only have port 80 open on the router.. so I am trying to view ruby on rails internally only from my main computer... my apache webserver till last night was headless and I just use putty or winscp to make changes.

    from my main computer I can go to the internal address http://192.168.0.100:1080/ and see the "welcome aboard" message.

    I tried to create the Hello World tutorial from another site.. it was based on ruby on windows though.. so I modified for Feisty Fawn..

    I go to http://192.168.0.10:1080/My_Test

    and it says "Page cannot be displayed"
    I started to modify things again to try to get it to work, after many times restarting apache webserver

    restart /etc/apache2/init.d

    *also it gives me an error about my default file having 2 virtual machines listed, but then says [ok] and I can open the home website no problems there.. I can open the "Welcome Aboard" page too. *

    in the tutorial it keeps talking about port 3000 and localhost...

    so I pull out the kvm switch and log into the desktop on Feisty Fawn pc..
    I go to 127.0.0.1:1080 - my home website (not the Welcome aboard ruby on rails it should be)

    127.0.0.1:3000 - page cannot be displayed

    seems I had to start webBrick on Ruby to get the page on
    ruby script/server (sorry I don't remember that one off the top of my head)

    127.0.0.1:3000 - "Hello World!!"

    http://127.0.0.1:3000/My_Test - works if webBrick is running

    So, after a long winded explanation, the big question is how to get http://192.168.0.10:1080/My_Test to work running off the Apache Webserver rather than the webBrick server.

    Feisty Fawn is running on an older P3 Dell Optiplex desktop tower.
    256MB RAM
    This is the info that shows on localhost if I type in a page that does not exist, I am thinking it may be helpful:
    Apache 2.2.3
    php/5.2.1
    mod_ruby/1.2.6
    Ruby/1.8.5(2006-08-25)
    mod_ssl/2.2.3
    open_ssl/0.9.8c
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Are there any errors in Apache's error log? What's the output of
    Code:
    netstat -tap
    ?
     
  3. TechG1rl

    TechG1rl New Member

    Contents of netstat -tap:

    Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
    tcp 0 0 localhost.localdom:2208 *:* LISTEN -
    tcp 0 0 *:mysql *:* LISTEN -
    tcp 0 0 *:netbios-ssn *:* LISTEN -
    tcp 0 0 *:www *:* LISTEN -
    tcp 0 0 localhost.localdoma:ipp *:* LISTEN -
    tcp 0 0 *:socks *:* LISTEN -
    tcp 0 0 *:smtp *:* LISTEN -
    tcp 0 0 *:https *:* LISTEN -
    tcp 0 0 *:microsoft-ds *:* LISTEN -
    tcp 0 0 localhost.localdom:2207 *:* LISTEN -
    tcp6 0 0 *:imaps *:* LISTEN -
    tcp6 0 0 *: pop3s *:* LISTEN -
    tcp6 0 0 *: pop3 *:* LISTEN -
    tcp6 0 0 *:imap2 *:* LISTEN -
    tcp6 0 0 *:ssh *:* LISTEN -
    tcp6 0 0 *:smtp *:* LISTEN -

    ***********

    Here is the bottom portion of the error log, I can send you the whole error log if you need it, but it seems to be repeating the same errors:

    OpenSSL/0.9.8c configured -- resuming normal operations
    [Thu Nov 22 01:09:21 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/MyTest
    [Thu Nov 22 01:09:21 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/error
    [Thu Nov 22 01:32:32 2007] [notice] caught SIGTERM, shutting down
    [Thu Nov 22 01:32:43 2007] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
    PHP Warning: Module 'json' already loaded in Unknown on line 0
    [Thu Nov 22 01:32:44 2007] [notice] Apache/2.2.3 (Ubuntu) PHP/5.2.1 mod_ruby/1.2.6 Ruby/1.8.5(2006-08-25) mod_ssl/2.2.3 OpenSSL/0.9.8c configured -- resuming normal operations
    [Thu Nov 22 01:32:59 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/MyTest
    [Thu Nov 22 01:32:59 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/error
    [Thu Nov 22 01:33:06 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/mytest
    [Thu Nov 22 01:33:06 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/error
    [Thu Nov 22 01:33:14 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/testapplication
    [Thu Nov 22 01:33:14 2007] [error] [client 192.168.0.158] File does not exist: /var/rails/testapplication/public/error
    [Thu Nov 22 01:37:58 2007] [notice] caught SIGTERM, shutting down
    [Thu Nov 22 01:38:09 2007] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec)
    PHP Warning: Module 'json' already loaded in Unknown on line 0
    [Thu Nov 22 01:38:10 2007] [notice] Apache/2.2.3 (Ubuntu) PHP/5.2.1 mod_ruby/1.2.6 Ruby/1.8.5(2006-08-25) mod_ssl/2.2.3

    Thank you for your help :) I am a little lost here.
     
  4. falko

    falko Super Moderator Howtoforge Staff

    Where did you create the My_Test file? It should be in /var/rails/testapplication/public/.
     
  5. TechG1rl

    TechG1rl New Member

    Hi,

    I typed in a command from the command line:

    ruby script/generate controller MyTest

    Then I modified the my_test_controller.rb

    so it looks like:
    Class MyTestController < ApplicationController
    def index
    render_txt "Hello World"
    end
    end

    *******

    Then, at 2am that night opening on the Feisty Fawn pc http://127.0.0.1:1080/My_Test

    said "hello world!!"

    but now I made some changes to try to fix things and broke them worse. Now that same page, says page cannot be displayed and 127.0.0.1:1080 opens my original family website rather than the "welcome aboard" ruby page.
     
  6. TechG1rl

    TechG1rl New Member

    Its working :)

    Hi,

    Just wanted to let you know after much searching online for info and looking through all the config pages I could find. I made many changes. But, the biggest setback to having both my website and rails running off apache for me, is a copy/paste error of all things!!

    i had this:
    ErrorLog /path/application/log/apache.log

    when it should have been

    ErrorLog /var/apache2/log/apache2.log or something similar to that.. once I fixed that the apache server restarted without error and I could open port 80 my family website and port 1080 internally on my home network opens up the rails application!!

    so now I can go to (from any pc on my home network):

    http://192.168.0.100:1080/My_Test

    and it displays "Hello World"

    ps. Falko, thank you so much for your patience and help here on the forum and for your many tutorials.. the last few days with late night searching for answers lead me on a wild goose chase.. one forum said the behaviour I was seeing was likely a virus on feisty of all things.. so I tried endlessly to install avg manually myself..following instructions from avg.. then I found your installing AVG on feisty article and it was installed right away!! No viruses.. just copy/paste error in my sites-enabled default file!!

    Do I need to close this thread?
     
Thread Status:
Not open for further replies.

Share This Page