I'm trying to setup Rails on the Ubuntu instance by using together with documentation for example https://help.ubuntu.com/community/RubyOnRails. I'm trying to setup the application in the Rails Getting Began page here: http://guides.rubyonrails.org/getting_started.html.

Things I did to date:

  • Installing of Ruby/RubyGems/Rails through RVM and Jewel (this installed Ruby 1.9.2 and Rails 3..7)
  • Installing of the mysql and mysql2 module (latter which did not work)
  • Development of rails application (blog application as tutorial is instructing)
  • Sym connecting of /home/me/www/blog/public/ from /var/www/blog/
  • Development of DB through rake
  • Installing of passenger module for Rails execution in Apache
  • Running of passenger-install-apache2-module to configure Apache
  • Deletion of public.html file from public/ rails application folder to ensure that my controller/view can fire
  • Configuration of websites-available files for virtual hosts
  • Configuration of Rails routing

I believe that it is the final two steps which are stumbling me up, partially because of insufficient knowledge of Apache and Rails (I'm a new comer to both).

During my virtual host file I'm attempting to indicate your blog public dir in /var/www/blog. For my Rails route I've root :to => "home#index" as instructed.

After I browse towards the http:// url I ought to normally be seeing my "Hello, Rails!" page per section 4.3 from the Getting Began guide, however all I see may be the directory listing from Apache. Static pages work although not Rails processing.

At this time I'm unclear when the passenger module is even doing anything or where you can search for any evidence of what's happening. I attempted something more important like running the Rails application off another virtual host known as "blog" at http:///blog and also the routing labored (static pages and all sorts of) but no Rails as above.

Update: after experimenting more, Now i customize the error message (404):

Not Found

The asked for URL /dispatch.cgi was not available on this server.

I've since determined this cgi 404 was triggered with a rewrite rule I'd put into .htaccess from guidance in the help.ubuntu.com page I stated above. Appears like it had not been necessary or put on a mature version of Rails. The incongruencies in instructions when searching for help on the internet is disorienting! Getting rid of the file leaves me using the previous problem though.

Here's the entry within the Apache log which i believe fits using the first error. Although I'm no more getting this error it appears, might be associated with another thing I had been trying before...

[Fri May 27 22:49:41 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9 with Suhosin-Patch Phusion_Passenger/3.0.7 configured -- resuming normal operations
[Fri May 27 22:51:18 2011] [error] [client 192.168.1.141] File does not exist: /var/www/blog/rails, referer: http://192.168.1.138/blog/

Here's the newest entry using the 404 around the cgi factor:

[Sat May 28 08:01:18 2011] [error] [client 192.168.1.141] File does not exist: /var/www/blog/dispatch.cgi

What could I be missing? Thanks!


Additional particulars as asked for. Apache sites file:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/blog/
    RailsEnv development

        # <Directory />
        #       Options FollowSymLinks
        #       AllowOverride None
        # </Directory>

        <Directory "/var/www/blog/">
        Options Indexes FollowSymLinks -MultiViews +ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
        # AddHandler cgi-script .cgi
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
    AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

Another update: I could have it working, finally, using a top level DocumentRoot (/var/www) and basing my Rails application off that using RailsBaseURI. This maps towards the "Implementing to some sub URI" portion of the Phusion Passenger instructions. It's used as http:///blog which isn't really things i desired to get, but it is type of irrelevant like me by using this simply to learn Rails inside a virtual. I require and focus on setting it up being employed as a high level application again sometime later. Here's my current (final) VirtualHost apply for reference:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        RailsEnv development

        <Directory /var/www/>
          Options FollowSymLinks
          AllowOverride None
        </Directory>

    RailsBaseURI /blog
        <Directory /var/www/blog/>
                Options Indexes FollowSymLinks -MultiViews +ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
                # AddHandler cgi-script .cgi
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>