I am a newbie (which you probably guessed from the subject) and have
just installed ruby 1.8.7, rails 2.3.5 and apache 2.2.12 on ubuntu 9.10.
I have created a rails app and edited my apache config as shown below.
The Rails “Welcome aboard” page displays, but when I click on “About
your application’s environment” I get
"Not Found
The requested URL /public/rails/info/properties was not found on this
server.
Apache/2.2.12 (Ubuntu) Server at localhost Port 80"
Can anybody tell me what I have done wrong?
Thanks in advance
Apache config at /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /home/henry/Projects/Project1
Options FollowSymLinks
AllowOverride None
<Directory /home/henry/Projects/Project1/>
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
allow from all
AddHandler cgi-script .cgi
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory “/usr/lib/cgi-bin”>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
Possible values include: debug, info, notice, warn, error, crit,
alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/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>
It all seems overwhelming at first, but it is quite easy to learn once
you get your head around how Rails does things in contrast to other
languages.
So a couple thoughts.
It sounds like you are running on a Linux distro. Ubuntu or Debian it
appears from the Apache directory structure.
Assuming that, do yourself a huge favor and install Passenger, and
scrap the CGI, it’s not worth the effort making it work. Go to Install — Phusion Passenger™ (a.k.a. mod_rails / mod_rack), and that will list out the
installation instructions.
Secondly, in your VirtualHosts file, you need to be pointing to your
public directory of your Rails apps, not the ROOT_DIR so to speak.
So DocumentRoot needs to be like “/home/henry/Projects/Project1/
public”.
I have always found it easiest to disable the default site, and make
my own VirtualHost file from scratch.
Here is what one of my VirtualHost files looks like on my Rails web
server:
Oh yes, I forgot to tell you how to disable the default site.
From the shell run “sudo a2dissite default”.
Then run your preferred editor, and create a new file in /etc/apache2/
sites-enabled, and name it whatever you want. I usually name it
something similar to the domain name of the app or site.
If you were to use vi, you do something like:
sudo vi /etc/apache2/sites-enabled/project1
I
<VirtualHost *:80>
…
ESC
:w
:q
And then you’d run “sudo a2ensite project1” (or whatever you named the
file)
And finally run “sudo /etc/init.d/apache2 reload”.
I’ve always used the gem, and I’ve never once had to run a2enmod, but
I suppose it depends on how you do it.
If you just add it to the bottom of /etc/apache2/apache2.conf, then
you don’t have to do that. Otherwise, yes, you’d have to use a2enmod.
Either way, it’s simple to do. Yes, a2ensite does in all actuality
create a symlink, but it’s a more seamless way of doing it with
distro’s that support the modularised implementation of Apache 2.
Then run your preferred editor, and create a new file in
/etc/apache2/sites-enabled
I think you mean creat a new file in /etc/apache2/sites-available
since a2ensite wants to create a symlink in sites-enabled to a file in
sites-available.
Similarly, if one uses the passenger gem rather than the passenger
package,
one creates files in /etc/apache2/mods-available, and uses a2enmod to
create
symlinks to them in /etc/apache2/mods-enabled.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.