SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Setting up erb/eruby on windows development pc

    [Where I'm coming from. You can skip this.]
    I'm going a bit crazy. I have learned Ruby and want to improve my skills by making my next website using embedded Ruby. I am coming from a few years of using PHP. So I don't know a lot, but I want to learn. Ruby has been really fun so far and want to see how it goes for developing websites. Maybe eventually moving on to Rails. But Ruby has taken my focus away from Rails for now.

    [My problem. I will be thankful if you read this.]
    I just want to get embedded rubby working! I installed InstantRails thinking that since it uses erb (right?) that it would automatically start parsing my .rhtml files for ruby morsels, but no go. I guess that doesn't happen until a Rails app is started. I've searched high and low and can't find anything that will easily setup a MySQL/Apache/(erb/e)Ruby server.

    If you can point me in the right direction to setup eRuby/erb with my InstantRails or XAMPP (an Apache/PHP/MySQL dev server thing) so that I can write Ruby like I write PHP, that would be wonderful. What ever is the easiest/quickest way.

    [Other info. What I've tried. You don't have to read this.]
    Some sites have pointed me towards MinGW to create a windows binary of eRuby and then installing it on an Apache server. But looking at the MinGW site scares me a bit. I was told I could get an eRuby Windows binary from that same site, but none can be found. Any help with this would be wonderful.

    I really, really want to start developing with Ruby. Right now I'm just creating a fun little text adventure, but that's just for fun. Though I do enjoy that, I want more.
    Last edited by donut2d; Aug 7, 2006 at 00:48. Reason: Clarity

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Oklahoma
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've never set it up before, but here are some keywords for you.
    eRuby when combined with apache, is typically called through mod_ruby. So make sure you get a mod_ruby first. I think erb/eRuby is included in the standard library these days, so it shouldn't be much more difficult than just getting mod_ruby installed for apache. But again, I've never set it up that way myself, so I can't help you much, but that ought to get you moving in a better direction.

  3. #3
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by donut2d
    [Where I'm coming from. You can skip this.]
    I'm going a bit crazy. I have learned Ruby and want to improve my skills by making my next website using embedded Ruby. I am coming from a few years of using PHP. So I don't know a lot, but I want to learn. Ruby has been really fun so far and want to see how it goes for developing websites. Maybe eventually moving on to Rails. But Ruby has taken my focus away from Rails for now.

    [My problem. I will be thankful if you read this.]
    I just want to get embedded rubby working! I installed InstantRails thinking that since it uses erb (right?) that it would automatically start parsing my .rhtml files for ruby morsels, but no go. I guess that doesn't happen until a Rails app is started. I've searched high and low and can't find anything that will easily setup a MySQL/Apache/(erb/e)Ruby server.

    If you can point me in the right direction to setup eRuby/erb with my InstantRails or XAMPP (an Apache/PHP/MySQL dev server thing) so that I can write Ruby like I write PHP, that would be wonderful. What ever is the easiest/quickest way.

    [Other info. What I've tried. You don't have to read this.]
    Some sites have pointed me towards MinGW to create a windows binary of eRuby and then installing it on an Apache server. But looking at the MinGW site scares me a bit. I was told I could get an eRuby Windows binary from that same site, but none can be found. Any help with this would be wonderful.

    I really, really want to start developing with Ruby. Right now I'm just creating a fun little text adventure, but that's just for fun. Though I do enjoy that, I want more.
    Gotcha covered. Read the tutorials in my signature and you should be popping out Ruby web pages in no time. All of them are from a windows user perspective. Specifically you want "eRuby: Getting Started with Ruby on the Web" which will show you how to get your Windows PC and your web host setup. There are links to the necessary files also.

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @Carl: Thanks a lot. I clicked the link in someone's (yours?) signature before, but I didn't catch the links to the files and was looking all over the minGW site for a binary. Alright, this looks slightly complicated for me. I'll post any questions I have. Thanks again!

    Quote Originally Posted by Sgarissta
    I've never set it up before, but here are some keywords for you.
    eRuby when combined with apache, is typically called through mod_ruby. So make sure you get a mod_ruby first. I think erb/eRuby is included in the standard library these days, so it shouldn't be much more difficult than just getting mod_ruby installed for apache. But again, I've never set it up that way myself, so I can't help you much, but that ought to get you moving in a better direction.
    Well, InstantRails comes with Ruby installed on Apache so that's not the problem. erb/eRuby doesn't magically work, unfortunately. I was kind of hoping it would be easier. But I think Carl's help will be close enough to what I want.

  5. #5
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, no success so far. But I'm probably doing something terribly wrong. At least, I'm hoping that I am.

    Checked through eRuby: Getting Started with Ruby on the Web tutorial. Went through step by step. Here's what I did with my limited Apache knowledge:

    I put the following at the bottom of my Apache's httpd.conf:

    Code:
    AddType application/x-httpd-eruby .rhtml
    Action application/x-httpd-eruby c:/ruby/bin/eruby.exe
    AddType application/x-httpd-cgi .rhtml
    ScriptInterpreterSource "registry"
    And added 'ExecCGI'/'+ExecCGI' (tried both) in the 'options' sections of the DocumentRoot <directory> part as well as tried with Aliased directories to other scripts.

    And I placed eruby.exe in the bin directory of InstantRuby as well as in the Ruby in InstantRails (tried both with InstantRails, no difference).

    I tried this on InstantRails and on XAMPP. If I have some more free time today before you guys respond I'll try it on Wampserver as well. I really, really want to get this working.

    Okay, what happens so far on both servers is that either it tells me I do not have permission to access the script (I'm using eruby_test.rhtml from the tutorial) or it just hangs and seemingly does nothing for what could be forever, but I get impatient and stop the page loading and try new things. But I have allowed it to hang like this for several minutes without a change.

    The trend seems to be this: On InstantRails (it did not already have ExecCGI) if I don't have the ExecCGI/+ExecCGI, it simply says that I don't have permission to view the file. After I add ExecCGI/+ExecCGI it just hangs.

    In XAMPP it already has ExecCGI on the DocumentRoot by default. So it just says 'permission denied' stuff. If I add +ExecCGI it screws up.

    Attached is the httpd.conf from InstantRails. Maybe that will be helpful.

    Thanks a lot!
    Attached Files Attached Files

  6. #6
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where are you running the files from? if you are using Instant Rails you haveto have a Shebang (Instant Rails runs Apache 1.3 which does not obey the ScriptInterpreterSource "registry" directive = bug) and you cannot run eRuby in a Rails app directory because or SCGI FCGI will not run eruby.exe

  7. #7
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Carl
    Where are you running the files from? if you are using Instant Rails you haveto have a Shebang and you cannot run eRuby in a Rails app directory because or SCGI FCGI will not run eruby.exe
    Which files? I'm running the eruby_test.rhtml in the htdocs/www DocumentRoot. eRuby I put into my InstantRuby installation's bin directory, as the tutorial said. I am not running eRuby from within a Rails app directory. What is a Shebang? Do you mean the "#!f:/ruby/bin/eruby.exe" line from the tutorial? I have that set to "#!c:/ruby/bin/eruby.exe" (where I put the eruby.exe file) in the eruby_test.rhtml, exactly as it is in the tutorial.

  8. #8
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have several installations of Apache ie. Instant Rails, Xammp or others then you will have to go to Windows Services and set the Apache service to manual. In most cases Xampp and others install the service and set it to auto start. If you start Instant Rails will kill itself and default to the Xampp instance (Windows service) because it is already running in the background. This is also true of MySQL. Set the service to manual so that you only get the Apache.exe server that Xammp or Intant Rails starts.

  9. #9
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already have it all set to manual. I hate having services running that don't need to be.

  10. #10
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your http.conf looks okay and you have the right services going. Are you running anything that might keep the eruby.exe from going like a firewall program, anti-virus or have tight permissions set on c:?

  11. #11
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check your instant rails apache error log and see what it is compalining about.

  12. #12
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh! I see the problem. Don't change your http.conf at all. Instant Rails already has a handler for .rhtml files (erb). So you are probably removing this association. You should be able to run an eruby file by just adding the shebang to the eruby.exe to the top of the file and doing nothing else.

    I also noticed that "restart" in Instant Rails does not work. You have to use stop then start to get a real Apache reboot

  13. #13
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instant Rails seems to be very unstable. After changing it to reproduce your error it refuses to go back to the original http.conf. It seems to be caching the changed settings.

    I would do as I do and use Wampserver for eRuby and Instant Rails for Rails apps.

  14. #14
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I disabled the Windows Firewall and AVG Free Antivirus and let it grind for over an hour try to load that page and it was still hanging when I got back. I'll check out Wampserver. Though, I was getting this same problem with XAMPP, which seems to be a reputable bundle thing. We'll see!

    Oh, the only errors my the (InstantRails) Apache log had were that have being forced to shut down after I tried loading the script. I'll check out Wampserver and see what happens.

    Thanks so much for your help!

  15. #15
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it does'nt run in the first secon then there is soething seriously wrong. No need to wait.

    If you get this going let me know the cure so that I can modify the tutorial. I want to let others know about things to watch out for. I will try it on Xampp lite and see what happens.

  16. #16
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, Wampserver is doing the same thing. Maybe there's something wrong with my Ruby installation? I dunno. I've gotta work now, but when I have time I'll delete everything related to Apache, Ruby and Rails and then reinstall piece by piece. This really sucks. Maybe I should just get a new webhost that comes with eRuby working and ready.

    And Wampserver is my new favorite webserver for Windows package! Thank you, Carl.
    Last edited by donut2d; Aug 8, 2006 at 17:16. Reason: Addition

  17. #17
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    It works! It works! RUBY LIVES! Oh, I am so very happy. I still don't know what was wrong. Maybe my Ruby installation had gone bad? I dunno. But I uninstalled everything as I said I would and it all seems to be working! I am so happy! Oh man. This is great! I can't wait to start working on my website, finally.

    So basically, I uninstalled everything. Reinstalled Wamp5, then installed InstantRuby and then configured the Wamp5 Apache httpd.conf and it's all happy happy joy joy from there.

    I'm gonna slowly try new things and then test it out again to make sure it works. If anything stops it I'll report back here for help Oh man, this is wonderful. It's such a relief. Thank you!

    I like Ruby so much and I haven't even finished a complete app yet. It's just so much more fun to write than PHP and I really enjoy writing PHP. Oh boy!

    I would assume that it was my Ruby installation being bad that was causing the problem since all of the servers that I had were having the same problem. Unless one of them messed it up for everyone.

    Update: Added the line "ScriptInterpreterSource "registry"" to the bottom of the httpd.conf and I started getting the same problem. Took it out and everything was honkey-doorey(sp?). But I thought I had tried removing that before in the past tests. Plus, the tutorial makes it sound as if having that before you've configured the registry really doesn't make a difference.

    Update 2: Alright, got the registry thing working so I don't have to have the shebang in every file. But there was some stuff that was confusing in the tutorial.

    First, I ran into a problem. Regedit wouldn't let me create a key (folder thing) that started with a '.' So I exported another key in HKEY_CLASSES_ROOT in the form of a .reg file. I edited it so that it would create the new key for me. That worked like a charm. Here's the code. Just stick it in notepad and save it with a .reg extension and type 'Any Files'. Change the path accordingly, of course.

    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\.rhtml\Shell\ExecCGI\Command]
    @="C:\ruby\bin\eruby.exe"
    Alright, my second problem came with what the tutorial told me to put into the default value of the key (above). Here's what it said (confusing parts bolded):

    Create a key HKEY_CLASSES_ROOT\.rhtml\Shell\ExecCGI\Command with the default value of the full path of perl.exe with a -T parameter. For example C:\ruby\bin\eruby.exe -T.
    And then the picture showed just "c:\ruby\bin\eruby.exe", no "-T" to be found. Well, the picture shows the truth. Adding the '-T' confuses the server. As for the perl.exe, I didn't even know perl was required to run eRuby For those who are taking this seriously: I'm joking! It's not. Ignore that part. Do not even think about anything perl right now.

    Once I figured that out, everything was smooth sailing. Thanks a lot Carl! Great tutorial! Exactly what I needed as you stated after my first post! Hope this helps.

    Update 3: Carl, one thing you may want to add to the tutorial is the code to get Apache to utilize index.rhtml files. You just need to add 'index.rhtml' to the DirectoryIndex' line. Like so:
    Code:
    DirectoryIndex index.php index.php3 index.html index.htm index.html.var index.rhtml
    Alright, now I need to go work on a quick design for my site Thanks again!
    Last edited by donut2d; Aug 9, 2006 at 01:21. Reason: I keep forgetting things!

  18. #18
    Web developer Carl's Avatar
    Join Date
    Sep 2003
    Location
    sweden
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    COOL!! I will make those changes and additions ASAP if not sooner.

    And that is a nice tip on using *.reg files to do the registry update. I had forgotten completely about those.

    I share your enthusiasm about being able to do Ruby straight off like PHP. The syntax and simplicity amazes me sometimes. So many things that take 50 lines of PHP only take 10 in Ruby.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •