Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: HOWTO: FastCGI/Apache & Ruby, Rails

  1. #1
    Join Date
    May 2006
    Beans
    3

    Lightbulb HOWTO: FastCGI/Apache & Ruby, Rails

    Installing RAILS on Ubuntu Breezy Badger

    Get ruby:

    The package below apparently installs an incompatible 1.8.3 version of the ruby interpreter.
    Code:
    sudo apt-get install ruby1.8
    On Breezy, try using the source package below, or perhaps obtain a 1.8.2 deb package?

    You can instead get a .tar.gz package, and compile it from source:

    Code:
    wget http://rubyforge.org/frs/download.php/2338/ruby-1.8.2.tar.gz
    cd ruby-1.8.2
    ./configure
    make
    make test
    sudo make install
    Get ruby gems:

    Go to:

    RubyGEMS

    And download the latest version, OR use the following wget command:

    Code:
    wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
    Then:

    Code:
    tar -xzf rubygems-0.8.11.tgz
    cd rubygems-0.8.11 
    sudo ruby setup.rb
    Install RAILS with Ruby Gems:

    Code:
    sudo gem install rails
    For now, do ‘NOT’ gem install mysql (Use the defaults if you plan to use mysql). I haven’t yet discovered a work around to a segfault problem that occurs. A future HOWTO to install the native mysql drivers is needed.

    Fixing Ubuntu Console readline problem

    You need to do this to run script/console for RAILS, or else you get the following error:

    /usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require’: no such file to load—readline (LoadError)

    Install curses and readline

    Code:
    apt-get install libncurses5-dev libreadline5-dev
    Manually make and install readline

    Code:
    cd ext/readline
    
    ruby extconf.rb
    
    make
    
    sudo make install
    Setup with FastCGI/Apache:

    Check out:
    Rails WIKI

    First, get libfcgi-dev (fcgi headers) and install the fcgi gem:

    Code:
    sudo apt-get install libfcgi-dev
    sudo gem install fcgi
    Configure apache httpd.conf

    Code:
    Alias /namefromroot/ /home/jason/public_html/railsap/public
        <Directory /home/jason/public_html/railsap/public>
            Options ExecCGI
            AddHandler cgi-script .cgi
            AddHandler fastcgi-script .fcgi .fcg .fpl
            AllowOverride all
            Order allow,deny
            Allow from all
        </Directory>
    And make a softlink to your public directory:

    Code:
    ln -s railsap/public /home/jason/public_html/railsap
    In the above configuration, I’m making a softlink to my rails project’s public directory, to my public_html directory. I then set an alias, namefromroot, to make it easier for people to access the root of my application.

    Add fastcgi to modules.conf

    Open modules.conf (/etc/apache/modules.conf on my system) with your favorite editor, and add the following line:

    Code:
    LoadModule fastcgi_module /usr/lib/apache/1.3/mod_fastcgi.so
    If you use Alias in httpd.conf for your rails directory, be sure to fix it!

    Edit public/.htaccess under your project, and add RewriteBase:

    Code:
    RewriteBase /namefromroot
    This will make it so that it redirects to the apropriate base directory.

    Also, change

    Code:
    RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
    to "RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    All Directories need a+r permissions, log directory needs write permissions “0666,” and all directories under tmp/ need write permissions to store session data, etc with.

    Code:
    chmod -R a+r app
    
    cd app/log/
    
    chmod a+w *
    or
    chmod 0666 *
    If you get an Rails application failed to start properly” Error

    Make sure there are no “puts” statements in your controllers!

    If it isn’t working after this:

    Clear out the session data from tmp/session, and make sure it’s writable. Also, clear the cookies in your browser, so it will try to make new session data.
    Last edited by TheDracle; May 3rd, 2006 at 09:30 PM.

  2. #2
    Join Date
    Apr 2006
    Location
    Phoenix, AZ
    Beans
    251
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: FastCGI/Apache

    There is one problem with this post. Breezy will isntall ruby 1.8.3 which IS NOT comptable with Rails 1.1. Dapper has ruby 1.8.4 and is comptable.

    ruby -v will spit out what version you are using.

  3. #3
    Join Date
    May 2006
    Beans
    3

    Re: FastCGI/Apache

    Perhaps it's a bit outdated--- my ruby version shows 1.8.2, on Breezy Badger. Must be out of date, I'll see if I can ammend it to get the right ruby version Thanks!


    From the RAILS website:

    We recommend Ruby 1.8.4 for use with Rails. Ruby 1.8.2 is fine too, but version 1.8.3 is not.

    -Jason Thomas.

  4. #4
    Join Date
    Apr 2006
    Location
    Phoenix, AZ
    Beans
    251
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: FastCGI/Apache

    Quote Originally Posted by TheDracle
    Perhaps it's a bit outdated--- my ruby version shows 1.8.2, on Breezy Badger. Must be out of date, I'll see if I can ammend it to get the right ruby version Thanks!


    From the RAILS website:

    We recommend Ruby 1.8.4 for use with Rails. Ruby 1.8.2 is fine too, but version 1.8.3 is not.

    -Jason Thomas.
    No problem

    I know I ran into this problem installing it just last week. Version 1.8.3 kept getting installed for me. I didn't realize at first that 1.8.3 wouldn't work AT ALL. I spent a lot of time banging my head on the wall re-reading all the howto's trying to figure out what I missed!

  5. #5
    Join Date
    Apr 2005
    Beans
    3

    Re: FastCGI/Apache

    is there a clean way to install ruby 1.8.2 or 1.8.4 on breezy? By clean I mean by using a package. I hate to manually install stuff as it tends to break future updates.

  6. #6
    Join Date
    May 2006
    Beans
    3

    Re: FastCGI/Apache

    Quote Originally Posted by pstreck
    is there a clean way to install ruby 1.8.2 or 1.8.4 on breezy? By clean I mean by using a package. I hate to manually install stuff as it tends to break future updates.
    I agree completely--- using a source tarball isn't a very good work around. I'd like to look into some work around using a 1.8.2 deb package maybe? Does anyone out there have some information relating to this?

  7. #7
    Join Date
    Mar 2006
    Location
    Denver, CO
    Beans
    392
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: FastCGI/Apache

    What about Dapper/apache2/fcgid?

    Documentation I've read so far has said to use fcgi instead of fastCGI on Apache 2, so that is how I've attempted to set it up.

    It looked like all the necessary items were available in Synaptic, so I installed them. However, although the ruby html test page comes up in my test app, rails doesn't seem to be working correctly. I tried adding a controller and got "page not found." Seems like something wrong with my configuration but I can't figure out what. Could someone post up/link to a sample .htaccess or something?

    EDIT: Found it! Near the bottom of this page is a great explanation of a virtual host setup, fcgi and the .htaccess file, as well as an example.
    Last edited by hotani; May 5th, 2006 at 05:15 PM.

  8. #8
    Join Date
    Jan 2006
    Location
    Edmonton, AB
    Beans
    122
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: HOWTO: FastCGI/Apache & Ruby, Rails

    For some reason the when I try to start the apache server with:
    /usr/local/apache2/bin/apachectl start

    I get an error message ( line 412 of the apache httpd.conf file) that the mod_fcgi.so file does not exist, and when I check, sure enough it is not there.

    Everything seemed to go good up to this point, including the install of the fastcgi. I am not sure if something got missed or what.

    Thanks for any help

  9. #9
    Join Date
    Jun 2006
    Beans
    32

    Re: HOWTO: FastCGI/Apache & Ruby, Rails

    Here's a question I have about it though. I follow you up to the editing the httpd.conf file, but when you set up the aliases, I start to worry.

    The thing is that I planned on setting this up on a multi-user system and wanted to have all users to be able to deploy rails code. But the alias seems to point the rails code from a specific user. Any way to get around this one?

  10. #10
    Join Date
    Jul 2006
    Beans
    Hidden!

    Re: HOWTO: FastCGI/Apache & Ruby, Rails

    I'm trying to fcgid to work on LAMPP, but at the moment the dispatch.fcgi is showing as plain text.

    http://pastebin.ca/86813 is my config.

Page 1 of 3 123 LastLast

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
  •