# Ruby on rails newbie please help cgi problem

**URL:** <https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828>\
**Category:** Rails\
**Created:** [October 13, 2008, 9:35pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828 "2008-10-13T21:35:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 13, 2008, 9:35pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/1 "2008-10-13T21:35:27Z")

</div>

Hi Just wondering I installed rails but cant seem to get any CGI scripts  
running i created a directory in the railsproject/public directory  
called cgi-bin which I gave Options +ExecCGI. Furthermore, I cant get  
any .rhtml files to parse embedded ruby. I find ruby on rails extremely  
complicated, this is my first experience with configuring apache and  
ruby on rails and I am getting very frustrated. I am running apache2 on  
ubuntu 7.10 I set up the virtual directory and am greeted with the  
riding on rails screen (however if i click about your applications  
environment i get an error). I am wondering if I should even be using  
rails as i programmed with ruby before using DBI modules for database  
connectivity and never had any problems. Mainly what I want to do is get  
embedded ruby working. I had this working before with eruby and the  
mod\_ruby module but i switched to mod\_rails and now everything has gone  
to crap. Any help is GREATLY appreciated, please bear in mind I am  
primarily a windows software programmer and am very new to ubuntu,  
apache and rails.

I placed this file in the available-sites directory called gridtest

`

    ServerName gridtest.com
    ServerAlias www.gridtest.com
    DocumentRoot /var/www/htdocs/railstest/public
    
       AllowOverride None
       Options +ExecCGI
       Order allow,deny
       Allow from all
    
  
`

Thanks,

Adam

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 13, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/2 "2008-10-13T21:54:36Z")

</div>

On Oct 13, 8:35 pm, Adam H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi Just wondering I installed rails but cant seem to get any CGI scripts  
> running i created a directory in the railsproject/public directory  
> called cgi-bin which I gave Options +ExecCGI. Furthermore, I cant get  
> any .rhtml files to parse embedded ruby. I find ruby on rails extremely  
> complicated, this is my first experience with configuring apache and  
> ruby on rails and I am getting very frustrated. I am running apache2 on  
> ubuntu 7.10 I set up the virtual directory and am greeted with the  
> riding on rails screen (however if i click about your applications  
> environment i get an error)

That may be a partial red herring - the stuff to display the  
application environment is not loading in production mode (which is  
what mod\_rails defaults to I believe. Dunno about the rest - I doubt  
many people writing rails apps use cgi scripts like that.

Fred

. I am wondering if I should even be using

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 14, 2008, 10:43pm UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/3 "2008-10-14T22:43:32Z")

</div>

> complicated, this is my first experience with configuring apache and  
> ruby on rails and I am getting very frustrated. I am running apache2 on

Maybe mod\_rails will help, as it simplifies deployment.  
Cheers!  
-=R

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 15, 2008, 4:49am UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/4 "2008-10-15T04:49:10Z")

</div>

Roger P. wrote:

> > complicated, this is my first experience with configuring apache and  
> > ruby on rails and I am getting very frustrated. I am running apache2 on
> 
> Maybe mod\_rails will help, as it simplifies deployment.  
> Cheers!  
> -=R

I have installed mod\_rails but still cant seem to get the embedded ruby  
working in .rhtml files. Do I need eruby for this if so how do I  
configure it with mod rails? Following is the configuration I had with  
eruby and mod\_ruby which was working before. It seems from what I have  
read that ruby comes with erb for embedding ruby in .rhtml and .erb.html  
files. I can revert back to these settings but I really want to  
understand what is going wrong here.

The following code was stored in /conf.d/ruby.conf

`
  AddType text/html .rhtml
  
    RubyRequire apache/ruby-run
    RubyRequire apache/eruby-run
```
# Execute *.rbx files as Ruby scripts
<Files *.rbx>
  SetHandler ruby-object
  RubyHandler Apache::RubyRun.instance
</Files>

# Handle *.rhtml files as eRuby files
<Files *.rhtml>
  ErrorDocument 500 /etc/apache2/customerror/error_500.rb
  SetHandler ruby-object
  RubyHandler Apache::ERubyRun.instance
</Files>

```
  
`

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 15, 2008, 9:56am UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/5 "2008-10-15T09:56:09Z")

</div>

On Oct 15, 3:49 am, Adam H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> configure it with mod rails?  
> Why aren’t you just letting rails render your templates?

Fred

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 16, 2008, 2:32am UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/6 "2008-10-16T02:32:10Z")

</div>

Frederick C. wrote:

> On Oct 15, 3:49ï¿½am, Adam H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > configure it with mod rails?  
> > Why aren’t you just letting rails render your templates?
> 
> Fred

Im sorry Im really knew to rails, what are these templates and how do I  
render them with rails.

I am also wondering is there any advantage to using rails if I write my  
own login script / use the DBI module for database connectivity? It  
seems from what I have heard that rails is primarily useful due to its  
easy of deployment. I want to become more familiar with rails because I  
keep hearing good things about it and it seems like it is quickly  
becoming very popular so I am just wondering what are the specific  
benefits?

Thanks,

Adam

---

<div class="post-metadata">

**Author:** ![omgitsads](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/dbc845/32.png) [@omgitsads](https://www.ruby-forum.com/u/omgitsads)\
**Post date:** [October 16, 2008, 2:50am UTC](https://www.ruby-forum.com/t/ruby-on-rails-newbie-please-help-cgi-problem/150828/7 "2008-10-16T02:50:53Z")

</div>

On 16 Oct 2008, at 01:32, Adam H. wrote:

> Im sorry Im really knew to rails, what are these templates and how  
> do I  
> render them with rails.

It sounds to me like you just want to dump some rhtml templates  
somewhere and have ruby render them. That’s fine, but that’s  
fundamentally not how rails work.  
Rails applications have a very specific structure. Your app splits  
into models, typically wrappers round a database table, controllers  
which sit between the outside world and your models, and views which  
are the .rhtml (now usually named .html.erb) files you were worrying  
about. Apache never touches a .rhtml file directly - it hands the  
request over to a rails worker (a mongrel, a fastcgi instance, a  
mod\_rails instance) which does a bunch of stuff (which may include  
rendering one of the app’s rhtml templates) and passes the response back  
I could waffle about this more, but I think that you would have more  
to gain by reading one of the many rails tutorials (make sure you pick  
a fairly recent one). I’d also advise that you forget about apache for  
a second.  
webrick/mongrel (which you can launch by running ruby script/server  
from the root of our app) are more than enough to get you going.

> 

While there are many great things about rails, I wouldn’t call ease of  
deployment its main strength (if anything historically it has been  
what puts people off).

Fred
