1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Ruby on Rails/FastCGI issues (no access to /public)

Discussion in 'Plesk for Linux - 8.x and Older' started by jimmyether, Apr 12, 2006.

  1. jimmyether

    jimmyether Guest

    0
     
    I'm having weird issues with Plesk and Ruby on Rails that I'm hoping someone here can help me out with. Anybody successfully running Rails with Plesk. I know there once was a very detailed three-part tutoral by a user here, but his site is now dead. So, I used these instructions:

    http://wiki.rubyonrails.com/rails/pages/HowtoInstallAndRunRubyOnRailsOnPlesk

    Basically, my apps have no access to their public directory. None of my images, javascripts, etc. are working in the app. Trying to access any of these results in a 404 (or
    routing error if in developer mode). Oddly, the 404 file it displays is -- you guessed it -- in fact *in* the public directory. Also, I'm getting all kinda of errors in apache error_log and suexec_log.

    Here is the rundown:

    RedHat ES3 with Plesk 7.5.4
    Apache2
    Ruby is at 1.8.4
    Rails at 1.1.2
    fcgi-2.4.0
    mod_fastcgi-2.4.2
    fcgi gem bindings

    Plesk has this nasty habit of wanting to control things (like it was asked to do... go figure). So, anything you write into httpd.conf gets overwritten on reboot. You get around this by including additional .conf files in /etc/httpd/conf.d/. So, I added the following fastcgi.conf:

    User apache
    Group apache
    LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so

    <IfModule mod_fastcgi.c>
    FastCgiWrapper on
    FastCgiConfig -idle-timeout 900
    FastCgiIpcDir /tmp/fastcgi_ipc/
    AddHandler fastcgi-script .fcgi .rb
    FastCgiServer
    /home/httpd/vhosts/mydomain.com/httpdocs/myapp/dispatch.fcgi
    -idle-timeout 120 -initial-env RAILS_ENV=production -processes 4
    </IfModule>

    The User and Group bit ends up being repeated in the httpd.conf, but it is necessary since Redhat loads anything in conf.d *before* the user and group declarations. Next, I make sure CGI is enabled for the domain in Plesk settings (if not, suexec will try to run the script as apache or root which results in an application that doesn't respond. Spent HOURS on that one!)

    Okay, so I upload myapp (which is set to rake freeze_gems at 1.1.1 btw) to the domain root (behind the www root). Chown -R to the correct domain user:group and chmod everything 755. I create a symbolic link named 'myapp' in the web root pointed to ../myapp/public and make sure owner
    is correct and it is chmod 777 as well. Then I go into myapp/public/.htaccess and make sure the dispatch.fcgi is uncommented
    and .cgi version is commented out. Next, I move over to myapp/config/ to change environment.rb to production mode. Then double check my database.yml settings to make sure they point at the MySQL databases.

    All good stuff right?

    We'll cool, I can log into myapp! But wait! I have no images. That's odd. And double-wait! My javascript isn't loading!! Oh no... all those
    AJAX actions... DEAD! And stylesheets? What are those?? :)

    From that point, I start looking into logs. Oh heck... the apache error_log has literally hundreds of these:

    [Wed Apr 12 14:08:23 2006] [warn] FastCGI: server
    "/home/httpd/vhosts/mydomain.com/httpdocs/myapp/dispatch.fcgi" has failed to remain running for 30 seconds given 3 attempts, its restart interval has been backed off to 600 seconds

    And likewise, suexec_log:

    [2006-04-12 14:08:23]: uid: (apache/apache) gid: (apache/apache) cmd: dispatch.fcgi
    [2006-04-12 14:08:23]: crit: cannot run as forbidden uid (48/dispatch.fcgi)

    Hmmm... odd that some of the app runs despite this. Only public is being hosed (well, and my logs!).

    Did a little more looking around and saw someone suggest to add the
    following to /vendor/rails/railties/lib/fcgi_handler.rb:

    require 'rubygems'
    require_gem 'fcgi'

    since I did indeed install the gems version.

    killed any ruby processes, cleaned out /tmp/fastcgi_ipc/, deleted any cookies for the domain and did apachectl -k graceful

    Went to the site, logged in, still no joy on public dir access. Greeeeat.

    So, I'm at a complete loss. The only other thing I was about to try in desperation to use mod_fcgid instead of mod_fastcgi. I don't really see how that would change anything with /public, but I'll try anything at this point.

    Suggestions?

    Ryan
     
Loading...