Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] Installation of Ruby; integration in Apache; Rails
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
cprior
n00b
n00b


Joined: 03 Jun 2004
Posts: 57
Location: #gentoo ;)

PostPosted: Wed Nov 10, 2004 3:00 pm    Post subject: [HOWTO] Installation of Ruby; integration in Apache; Rails Reply with quote

Installation of Ruby; integration in Apache; Rails

The mid-term break called for sth. productive and I decided to poke around in Ruby.
ruby-lang.org wrote:
Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable.


Most of the current packages required are in portage.

At first, the language itself:

Code:
emerge dev-lang/ruby


This depends on dev-ruby/ri (interactive help), dev-ruby/ruby-config, dev-ruby/text-format. Interestingly, ruby-config also depends on an older version of dev-lang/ruby, which gets installed in another slot. I do not know (yet) if that's desired or a bug; however, it did not hurt with the first steps either. Update: This behaviour changed and ruby-config no longer installs a slotted dependency. (Currently ruby-1.8.2 and ruby-config -0.3.1 on 11th of february 2005)

Now you can already use the interactive Ruby shell: Start it with irb --simple-prompt and you will be greeted by an unspectacular prompt >> . I made an alias in .bashrc for the shortcut rb right away:

In ~/.bashrc I wrote:
alias rb='clear && irb --simple-prompt'


To just explore the langauage this installation is already enough. I recommend the online book Programming Ruby, The Pragmatic Programmer's Guide, First Edition, aka PickAxe. If you feel that the Euro is especially strong and the Dollar cheap, you might as a citizen of the Euroarea consider buying the new one for 25 USD. Update: Make sure to get the 2nd edition.
You can safely stop at this point and start enjoying the language.* The following is by no means necessary for a first impression as the interactive shell and the possibility to have files interpreted is more than enough for a short mid-term break! ;-) Anyhow, as Gentoo users have been said to "compile it, if it moves!", I could not resist at all:

To prepare Ruby for higher tasks, we make it capable of talking to some databases, adding the PostgreSQL extension to package.keywords -- the example is for x86 machines:

Code:
echo "=dev-ruby/plruby-0.4.2 ~x86" >> /etc/portage/package.keywords && \
emerge mysql-ruby plruby ruby-dbi


And finally we want Ruby to work with Apache:

Code:
emerge eruby mod_ruby


What eruby does is enabling embedded Ruby in otherwise html files, similar to embedded PHP. It is usually configured in Apache for the file suffix .rhtml and might look like this:

In ruby.rhtml I wrote:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html><head><title>eruby example</title></head>
<body>
<h1>Enumeration</h1>
<ul>
<%(1..10).each do|i|%>
<li>number <%=i%></li>
<%end%>
</ul>
</body></html>


In contrast to this we can also use Ruby just like cgi scripts, the following setup will prepare for these kind of files to be executed:

In ruby.rbx I wrote:
#!/usr/bin/ruby
puts "Hello World"


In the meanwhile the emerge should have finished. Just like a PHP install, emerge does tell us to add an option to /etc/conf.d/apache2.conf If you have already PHP installed, make it look like this.

In /etc/conf.d/apache2 I wrote:
APACHE_OPTS="-D PHP4 -D RUBY"


But just as a PHP install, emerge does _not_ tell us to load the appropriate module in /etc/apache2/conf/apache2.conf: I just added this line right underneath my similar looking php4_module directive. Update: The ebuild now spits out the following remark:

Quote:
* To enable mod_ruby, edit /etc/conf.d/apache2 and add "-D RUBY"
* You may also wish to edit /etc/apache2/conf/modules.d/20_mod_ruby.conf
* You must restart apache for changes to take effect


It is no longer necessary to add a directive for loading the module.

The change to /etc/conf.d/apache2 enables mod_ruby, but not eruby, the embedded interpreter. We have to comment out the lines in /etc/apache2/conf/modules.d/20_mod_ruby.conf from the line RubyRequire apache/eruby-run on, the block about Location and Files included.
We also need to comment out the block after # exec *.rbx as ruby scripts.

I assume that every Gentoo installation has mod_rewrite enabled in
/etc/apache2/conf/apache2.conf:

In /etc/apache2/conf/apache2.conf I wrote:
LoadModule rewrite_module modules/mod_rewrite.so


Most computer problems originate 60cm away from the screen and thou shalt not forget to do the requested

Code:
/etc/init.d/apache2 restart


Now you can put the above files ruby.fhtml and ruby.rbx somewhere under your document root. Caveat: If you did not use cgi scripts in your ~/public_html or whatever a possible userdir on your machine might be, you better go for somewhere in /var/www/localhost/htdocs. (This will be from now on referred to as $DOC_ROOT) **

So a browser request to http://localhost/ruby.rhtml will count for you from 1 to 10, if you used my example from above.

To install the highly praised framework Ruby on Rails http://rubyonrails.org on our machine, we need at first RubyGems, which is not on portage. So we download the latest version from http://rubygems.rubyforge.org/ and unpack it to some place: Update: now available via Bugzilla. I therefore deleted all old instructions and replaced them with the updated (11th of february 2005) instructions below:

At first we need the ebuilds -- bug no. 80828 lists them all in its dependency tree:

Quote:
Bugs that bug 80828 depends on
( view as bug list)
80823 [ruby@gentoo.org] - gems.eclass (Ruby gems installer).
80824 [ruby@gentoo.org] - dev-ruby/actionmailer (New Package).
80825 [ruby@gentoo.org] - dev-ruby/actionpack (New Package).
80826 [ruby@gentoo.org] - dev-ruby/activerecord (New Package).
80827 [ruby@gentoo.org] - dev-ruby/rake (gems version).


Download them all and put them in your overlay, e.g. /usr/local/portage:

Code:
cd /usr/local/portage  && mkdir actionmailer actionpack activerecord rake
# snip: copy the downloaded ebuilds in their directory
# and create the checksums
# [b]gems.eclass belongs to /usr/portage/eclass/[/b]
ebuild /usr/local/portage/dev-ruby/rails/rails-0.9.5.ebuild digest
ebuild /usr/local/portage/dev-ruby/rake/rake-0.4.15-r1.ebuild digest
ebuild /usr/local/portage/dev-ruby/actionpack/actionpack-1.4.0.ebuild digest
ebuild /usr/local/portage/dev-ruby/activerecord/activerecord-1.6.0.ebuild digest
ebuild /usr/local/portage/dev-ruby/actionmailer/actionmailer-0.6.1.ebuild digest


So all that is left now is to

Code:
emerge -v rails


which typically shows dependencies like:

Code:
# emerge rails -vp

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild  N    ] dev-ruby/sqlite-ruby-2.2.2  55 kB
[ebuild  N    ] dev-ruby/ruby-postgres-0.7.1  28 kB
[ebuild  N    ] dev-ruby/rubygems-0.8.4  132 kB
[ebuild  N    ] dev-ruby/activerecord-1.6.0  0 kB [1]
[ebuild  N    ] dev-ruby/actionpack-1.4.0  0 kB [1]
[ebuild  N    ] dev-ruby/actionmailer-0.6.1  0 kB [1]
[ebuild  N    ] dev-ruby/rake-0.4.15-r1  0 kB [1]
[ebuild  N    ] dev-ruby/rails-0.9.5  +mysql +postgres +sqlite 0 kB [1]

Total size of downloads: 216 kB
Portage overlays:
 [1] /usr/local/portage


You should now be able to install a first test application. I created a directory at first:

Code:
export DOC_ROOT=/var/www/localhost/htdocs/
mkdir $DOC_ROOT/rails
rails $DOC_ROOT/rails


The default paths in some of the installed files have to be changed. Replace all shebang lines with #!/usr/bin/ruby or nothing will work. Update: No longer necessary.

Test if the installation was successful:

Code:
htdocs $ ls rails/
CHANGELOG  Rakefile  config  doc  log     script  vendor
README     app       db      lib  public  test


Now you should be greeted by a page beginning with "Congratulations, you're on Rails!" by browsing to http://localhost/rails/public/ (depending on your Apache setup the trailing slash is important)

For the sake of completion, the following lines will show if Rails is working:

Create a sample database in MySQL:

Code:
mysql -u root -p -h localhost
mysql> CREATE DATABASE rails_production;
mysql> CREATE DATABASE rails_test;
quit


Edit config/database.yml to reflect your setup.

And create a basic application (taken from the included help)

Code:
script/new_controller Blog list display new edit


A simple test can be performed typing
Code:
rake


A first Rails-generated page can be accessed with
http://localhost/rails/public/dispatch.cgi?controller=Blog&action=display
It should look somewat like

Blog#display
Find me in app/views/blog/display.rhtml

If not, and no careful reading of my above script-excerpt help upon second examination, feel free to annotate your suggestions for enhancements.

If your browser shows permissions problems or even the plain file contents, try ruby filename on the file. It should interprete the file and you know at least it's Apache-related.

---------------
* I love the type "ranges", how you can "extend" a class or module by kinda appending, found the yield iterator interesting and like the overall logic. But I am just "interested public", no programmer.
** Hint: To enable Apache to access your ~/public_dir, add apache to your users group and chmod g+x /home/yourUsername. Apache needs to traverse into it. Notice how g+x does not imply read access.


Last edited by cprior on Fri Feb 11, 2005 8:14 pm; edited 5 times in total
Back to top
View user's profile Send private message
drinian
Tux's lil' helper
Tux's lil' helper


Joined: 01 Feb 2004
Posts: 81
Location: Maryland

PostPosted: Mon Dec 20, 2004 9:11 pm    Post subject: Reply with quote

I might add that RubyGems is now in Portage.

Also, you can install the latest version of Rails simply by typing:

Code:

gem install -r rails


Thanks for the HOWTO!
Back to top
View user's profile Send private message
Dolio
l33t
l33t


Joined: 17 Jun 2002
Posts: 650

PostPosted: Tue Dec 21, 2004 6:24 am    Post subject: Reply with quote

The Pickaxe is an excellent book. However, if you're going to actually buy it, make sure you get the second edition, with all sorts of new and updated stuff.

ruby-doc.org is also a good online reference if you need brief descriptions of methods and classes.
_________________
They don't have a good bathroom to do coke in.
Back to top
View user's profile Send private message
nazgum
Tux's lil' helper
Tux's lil' helper


Joined: 19 Apr 2003
Posts: 111
Location: Canada

PostPosted: Tue Jan 25, 2005 8:08 pm    Post subject: Reply with quote

I really like ruby and saw rails and knew I must install this =)


It "seems" like I have this working, except I am having some problems with it.

Anyone able to post their apache configuration they have for this?

I'm certain that is where my problem is.

Cheers!

Edit: I fixed this by using vhosts from their tutorial rather then trying it without[/b]
_________________
Jabber: nazgum@jabber.org
Back to top
View user's profile Send private message
nazgum
Tux's lil' helper
Tux's lil' helper


Joined: 19 Apr 2003
Posts: 111
Location: Canada

PostPosted: Wed Jan 26, 2005 9:44 pm    Post subject: Reply with quote

hehe well I thought I got this all working, except it is not =p

Following the excellent ruby on rails tutorial at:

http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=3

You make a recipe example.

I've setup the database and the controller,

Browsing to rails/Recipe

Does list items already in the database - the links beside the item for show edit and destroy all do not work. The new at the bottom also does not work.

Going to rails/Recipe/new

Does bring me to a page to add info to my mysql database with the proper fields, but filling them out and clicking create does NOT bring me to the list view and does NOT add the information to my mysql database.

Anyone available for help on this one? =)

I'd really love to get this working, as it looks like a very nice tool =)

Edit: ALL of my problems stemmed from http://rails/Recipe to http://rails/recipe [MUST be lowercase]

ehe tutorial had it uppercase and i presumed that is how it must be, so if anyone else gets stuck on that this is your answer.
[/b]
_________________
Jabber: nazgum@jabber.org
Back to top
View user's profile Send private message
Pythonhead
Developer
Developer


Joined: 16 Dec 2002
Posts: 1801
Location: Redondo Beach, Republic of Calif.

PostPosted: Sat Feb 05, 2005 7:05 am    Post subject: Reply with quote

I've written a gems eclass so we can install Rails and the four packages it depends on via ruby gems:

https://bugs.gentoo.org/show_bug.cgi?id=80828

Be sure to look at the bug's dependency tree and install all the ebuilds if you want to try it out.

EDIT: dev-ruby/rails is now in portage
Back to top
View user's profile Send private message
Pythonhead
Developer
Developer


Joined: 16 Dec 2002
Posts: 1801
Location: Redondo Beach, Republic of Calif.

PostPosted: Thu Feb 17, 2005 9:06 pm    Post subject: Reply with quote

Here is a quick HOWTO for creating a very simple cookbook using Ruby on Rails with sqlite and Ruby's lightweight web server. (This is the 2 minute Linux version of the above mentioned onlamp.com Windows 5 page tutorial ;)

Code:
USE='sqlite' emerge dev-ruby/rails


As your regular (non-root) user:

Code:
rails Cookbook
cd Cookbook
{$EDITOR} config/database.yml
(replace with my database.yml below)
${EDITOR} db/schema
(paste my schema below)
sqlite db/recipes_test.db < db/schema
./script/generate model Recipe
./script/generate controller recipe
${EDITOR} app/controllers/recipe_controller.rb
Edit file to look like:
class RecipeController < ApplicationController
    model :recipe
    scaffold :recipe
end

./script/server

Point your browser at: http://localhost:3000/recipe/
Test your new cookbook app. This is very basic, but you can see how easy it is to
get a web app started. You can modify the SQL table, add some new fields and then
simply refresh the browser and the form will be updated without changing any code.

When you're ready to go into production, check out Cookbook/README on how to get it
working with apache.

Sample code:

config/database.yml
Code:

development:
  adapter: sqlite
  dbfile: db/recipes_test.db

test:
  adapter: sqlite
  dbfile: db/recipes_test.db

production:
  adapter: sqlite
  dbfile: db/recipes_test.db


db/schema
Code:

CREATE TABLE 'recipes' (
'id' INTEGER PRIMARY KEY NOT NULL,
'title' VARCHAR(255) DEFAULT NULL,
'description' VARCHAR(255) DEFAULT NULL,
'instructions' TEXT DEFAULT NULL
);
Back to top
View user's profile Send private message
emlyn
n00b
n00b


Joined: 30 Mar 2005
Posts: 2

PostPosted: Tue May 17, 2005 8:37 am    Post subject: getting mod_ruby to start with apache2 Reply with quote

I've been following the howto at the top of this thread (which is very nicelly written btw), and I seem to have gotten myself stuck when it comes to getting mod_ruby to load. I'm running apache-2.0.54-r5, which is not a 'stable' version, but at the moment using ~x86 for apache is necessary if one wants to run PHP5. I have experience with mod_php, but I"ve never used ruby before.

What Works

I've emerged ruby, and it works.

I've emerged eruby, and mod_ruby, and I can used eruby directly. For example, for example, I've put the eruby script provided in the howto into /var/www/localhost/htdocs/rubytest.rhtml, and if I call;

eruby /var/www/localhost/htdocs/rubytest.rhtml

I get the expected output.

What Doesn't Work

If I try and browse to that same location (http://localhost/rubytest.rhtml), I see the source of the script, not the result. And no, I didn't forget to restart apache, in fact I've done it every step of the way. :)

I believe that mod_ruby isn't being correctly loaded. I have added the -D RUBY to /etc/conf.d/apache 2, and I don't see any errors in the apache2 error_log when I restart it. However, I look at a page generated by the phpinfo() function (which lists all loaded apache modules), I don't see mod_ruby.

I suspect that this may have something to do with the current changes in apache configuration. I currently have module config files in two directories; /etc/apache2/conf/modules.d and /etc/apache2/modules.d. I seem to have the file 20_mod_ruby.conf in both of them. Suggestions would be welcome. My eventual goal is to try and install rails. I've tried messing round with fastcgi and I didn't even get this far (mainly because I didn't understand the process). I'd rather use mod_ruby anyway, because it seems more similar to what I do with php. I've tried re-emerging various packages, but that doesn't help

thanks

Craig
Back to top
View user's profile Send private message
Pythonhead
Developer
Developer


Joined: 16 Dec 2002
Posts: 1801
Location: Redondo Beach, Republic of Calif.

PostPosted: Tue May 17, 2005 3:20 pm    Post subject: Reply with quote

In this file :
/etc/apache2/conf/apache.2.conf

Do you have?
Code:
LoadModule ruby_module                /usr/lib/apache2-extramodules/mod_ruby.so


And in /etc/apache2/conf/modules.d/20_mod_ruby.conf
Code:

<IfDefine RUBY>
  <IfModule !mod_ruby.c>
    LoadModule ruby_module    extramodules/mod_ruby.so
  </IfModule>
</IfDefine>

# taken from the example file
# If the ruby module is installed, this will be enabled.
<IfModule mod_ruby.c>
  # for Apache::RubyRun
  RubyRequire apache/ruby-run
  #Required by rails:
  RubySafeLevel 0

  # exec files under /ruby as ruby scripts.
  <Location /ruby>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    Options ExecCGI
  </Location>

  <Files *.rb>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
</IfModule>


You may need to uncomment this:
Code:

  # # handle *.rhtml as eruby files.
  # <Files *.rhtml>
  #   SetHandler ruby-object
  #   RubyHandler Apache::ERubyRun.instance
  # </Files>


The important line to get mod_ruby working with Rails is this:
Code:
  RubySafeLevel 0


fastcgi can be a pain to configure, but if you find mod_ruby too slow it will be worth the effort to setup fcgi. Check my configs in this post:
https://forums.gentoo.org/viewtopic-t-303278-highlight-modruby.html
Back to top
View user's profile Send private message
emlyn
n00b
n00b


Joined: 30 Mar 2005
Posts: 2

PostPosted: Wed May 18, 2005 1:14 am    Post subject: Reply with quote

Thanks Pythonhead,

I don't appear to have a /etc/apache2/conf/apache.2.conf file. Or in fact a file of that name in any directory.

However, in /etc/apache2/httpd.conf there are many LoadModule statements, for things like mod_auth and heaps of others. 'External modules', such as mod_php, don't seem to be there, instead there is the line:
Code:
Include conf/modules.d/*.conf


I presume that is loading all files matching that pattern. Certainly that should include the mod_ruby configuration file which is present at:
Code:
/etc/apache2/conf/modules.d/20_mod_ruby.conf


The load module bit in this file looks like this:
Code:
<IfDefine RUBY>
  <IfModule !mod_ruby.c>
    LoadModule ruby_module    extramodules/mod_ruby.so
  </IfModule>
</IfDefine>


That .so file is present in my system at "usr/lib/apache2-extramodules/mod_ruby.so", so I've tried changing the above block to:
Code:
<IfDefine RUBY>
  <IfModule !mod_ruby.c>
    #LoadModule ruby_module    extramodules/mod_ruby.so
    LoadModule ruby_module      /usr/lib/apache2-extramodules/mod_ruby.so
  </IfModule>
</IfDefine>


...just in case. But this doesn't seem to help. Perhaps mod_ruby is being loaded correctly, and it is the rest of the configuration which is wrong (although that doesn't explain mod_ruby not being listed on the phpinfo() page).

The rest of my 20_mod_ruby.conf file looks like this:

Code:
<IfModule mod_ruby.c>
  # for Apache::RubyRun
  RubyRequire apache/ruby-run
  # Requred by rails:
  RubySafeLevel 0

  # exec files under /ruby as ruby scripts.
  <Location /ruby>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    Options ExecCGI
  </Location>

  # exec *.rbx as ruby scripts.
  <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>
</IfModule>


I've tried changing the *.rbx section to *.rb so that it matches your example, but that doesn't help. I've also tried adding an identical section for *.rhtml but that doesn't help either. The file I'm testing against is a .rhtml file, so I'm not sure if apache is being told to execute that as eruby.

So I'm still stuck. Just to confirm again, my -D RUBY is definatelly in place, and I'm definatelly remembering to restart apache2.

thanks,

Craig
Back to top
View user's profile Send private message
NorthGoingZax
Apprentice
Apprentice


Joined: 03 Dec 2002
Posts: 189

PostPosted: Sat Jul 16, 2005 4:31 am    Post subject: Reply with quote

I followed this howto, and I am getting the following in my error.log:
[code]
Fri Jul 15 22:34:07 2005] [notice] Apache/2.0.54 (Gentoo/Linux) PHP/4.3.11 mod_ruby/1.2.4 Ruby/1.8.2(2004-12-25) configured -- resuming normal operations
[Fri Jul 15 22:34:15 2005] [error] mod_ruby: error in ruby
[Fri Jul 15 22:34:15 2005] [error] mod_ruby: (eval): (eval): uninitialized constant Apache::ERubyRun (NameError)
[Fri Jul 15 22:34:15 2005] [error] mod_ruby: from (eval):0:in `value'

[/code]
What am I missing?
Back to top
View user's profile Send private message
Dizzutch
Guru
Guru


Joined: 09 Nov 2004
Posts: 463
Location: Worcester, MA

PostPosted: Mon Sep 05, 2005 7:00 pm    Post subject: Reply with quote

I'm getting the same error, not sure what's going on with it.
Back to top
View user's profile Send private message
Dizzutch
Guru
Guru


Joined: 09 Nov 2004
Posts: 463
Location: Worcester, MA

PostPosted: Mon Sep 05, 2005 7:13 pm    Post subject: Reply with quote

I just uncomented everything in /etc/apache2/modules.d/21_mod_ruby.conf

Code:

<IfDefine RUBY>
  <IfModule !mod_ruby.c>
    LoadModule ruby_module    modules/mod_ruby.so
  </IfModule>
</IfDefine>

# taken from the example file
# If the ruby module is installed, this will be enabled.
<IfModule mod_ruby.c>
  # for Apache::RubyRun
  RubyRequire apache/ruby-run

  # exec files under /ruby as ruby scripts.
  <Location /ruby>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    Options ExecCGI
  </Location>

  # exec *.rbx as ruby scripts.
  <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
  </Files>

  # # for Apache::ERubyRun
   RubyRequire apache/eruby-run
  #
  # # handle files under /eruby as eRuby files by eruby.
   <Location /eruby>
     SetHandler ruby-object
     RubyHandler Apache::ERubyRun.instance
     Options ExecCGI
   </Location>
  #
  # # handle *.rhtml as eruby files.
    <Files *.rhtml>
      SetHandler ruby-object
     RubyHandler Apache::ERubyRun.instance
   </Files>

  # # for Apache::ERbRun
   RubyRequire apache/erb-run
  #
  # # handle files under /erb as eRuby files by ERb.
   <Location /erb>
     SetHandler ruby-object
     RubyHandler Apache::ERbRun.instance
     Options ExecCGI
   </Location>

  # # for debug   
   RubyRequire auto-reload
</IfModule>

this works for now, I'll figure out later what exactly it was.
Back to top
View user's profile Send private message
metalhedd
l33t
l33t


Joined: 30 May 2002
Posts: 692
Location: Ontario Canada

PostPosted: Sun Sep 11, 2005 5:49 pm    Post subject: Reply with quote

I've managed to get ruby to work properly, the test script works, apache doesn't seem to have any problem with its config. the issue I'm having is in getting rails working. I've created a directory in my /var/www/localhost/htdocs/intranet/ called links (to manage a collection of links) create the rails framework, generated the database tables etc. basically followed the recipe tutorial to a tee. however apache just gives me a directory listing when I browse http://localhost/intranet/links/ I dont know how to actually access my rails program through apache.
Back to top
View user's profile Send private message
Pistos
Apprentice
Apprentice


Joined: 29 Jul 2003
Posts: 175
Location: Canada

PostPosted: Mon Sep 26, 2005 3:07 pm    Post subject: Reply with quote

Code:
uninitialized constant Apache::ERubyRun (NameError)
I recently had this problem on two servers. The problem is, you need to uncomment this:
Code:
RubyRequire apache/eruby-run
in order for Apache to load eRuby.

It seems this Apache upgrade has caused the old 20_mod_ruby.conf file to get replaced with a default 21_mod_ruby.conf file, which has lots of things commented out.
Back to top
View user's profile Send private message
realAzrael
n00b
n00b


Joined: 19 Aug 2004
Posts: 3

PostPosted: Sun Feb 05, 2006 1:02 pm    Post subject: Reply with quote

same problem here, emlyn

i dont have a file /etc/apache2/conf/apache.2.conf

/etc/apache2/httpd.conf
looks at /etc/apache2/modules.d/ for modules, but the file was in /etc/apache2/conf/modules.d/20_mod_ruby.conf
so i cp to the right location and got this error:

Code:
# cp /etc/apache2/conf/modules.d/20_mod_ruby.conf /etc/apache2/modules.d/
# /etc/init.d/apache2 restart
 * Apache2 has detected a syntax error in your configuration files:
Syntax error on line 3 of /etc/apache2/modules.d/20_mod_ruby.conf:
Cannot load /usr/lib/apache2/extramodules/mod_ruby.so into server: /usr/lib/apache2/extramodules/mod_ruby.so: cannot open shared object file: No such file or directory


i found that file at /usr/lib/apache2-extramodules/mod_ruby.so
i could change that line, but i copied the file to the right place

Code:
# mkdir /usr/lib/apache2/extramodules
# cp /usr/lib/apache2-extramodules/mod_ruby.so /usr/lib/apache2/extramodules/


Restarted Apache and here we go! eruby works
i can browse on my ruby.rhtml and see the result

i tried with ruby.rbx, but my browser keeps saying:
Quote:
Forbidden
You don't have permission to access /ruby.rbx on this server.


any ideas?
Back to top
View user's profile Send private message
realAzrael
n00b
n00b


Joined: 19 Aug 2004
Posts: 3

PostPosted: Sun Feb 05, 2006 2:16 pm    Post subject: Reply with quote

uhm, i forgot the Options ExecCGI in my /etc/apache2/modules.d/20_mod_ruby.conf

Code:
 <Files *.rbx>
    SetHandler ruby-object
    RubyHandler Apache::RubyRun.instance
    Options ExecCGI
 </Files>


works fine now
Back to top
View user's profile Send private message
- LeChuck -
n00b
n00b


Joined: 27 Jun 2005
Posts: 29
Location: Mêlée Island

PostPosted: Mon Feb 06, 2006 3:32 pm    Post subject: Reply with quote

I followed this instruction a few times, already re-installed apache, and still get as *.rbx output a plain text instead of html. I absolutely have no more clue. My 21_mod_ruby.conf looks correct, also vhosts.conf. I tried ExecCGI at .htaccess or vhosts.conf, without success. Eruby runs perfect btw. I'm no apache guru, and may have overseen something (mime, scriptalias, cgi-bin, ... don't know). With FastCGI I got same. Apache logs show no errors.
_________________
.. Look behind you, a three headed monkey! ...
Back to top
View user's profile Send private message
paulfleetwood
n00b
n00b


Joined: 26 Jul 2006
Posts: 1

PostPosted: Thu Jul 27, 2006 12:05 am    Post subject: Getting mod_ruby working per the Pragmatic Programmers book Reply with quote

I have gotten mod_ruby working (instead of eruby from the cgi-bin directory per the Pragmatic Programmers book (http://www.rubycentral.com/book/web.html)).

Here are the steps I performed.

I added index.rhtml to the end of the DirectoryIndex line in /etc/apache2/httpd.conf file (just like the book says), like so:
Code:
DirectoryIndex index.html index.html.var index.rhtml


This enables apache to find index.rhtml as the "base" document of a folder, in my case "http://127.0.0.1/rubytest".

But that only showed the ruby code, and didn't execute it. For that to happen, I also had to (again, as the book instructs), add "-D RUBY" to the "APACHE2_OPTS=" line in /etc/conf.d/apache2.

But, that was not enough. I also had to edit the /etc/apache2/modules.d/21_mod_ruby.conf file so that these lines were not commented out:
Code:
RubyRequire apache/eruby-run
<Files *.rhtml>
     SetHandler ruby-object
     RubyHandler Apache::ERubyRun.instance
</Files>


Apparently, the RubyRequire line above is what makes the mod_ruby actually take the place of eruby. And the <Files...> section says if a file ending with *.rhtml is encountered, it should be interpretted with eruby.

Because of these changes, the "AddType" and "Action" lines that the book suggested were not necessary. The instructions with the book work fine as-is, but don't deliver the performance improvement they mention, which comes from mod_ruby.
_________________
Cheers,
PMF
Back to top
View user's profile Send private message
flaab_0n
Guru
Guru


Joined: 27 Dec 2003
Posts: 470
Location: /España/Madrid/Alcorcon

PostPosted: Thu Mar 08, 2007 2:25 pm    Post subject: Reply with quote

I got it!! Yeah!!

Thanks a lot!
_________________
[ _Flaab_0n ]

www.quinielalosases.com
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum