SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Hybrid View

  1. #1
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hello world in apache 2.0 + WinXP

    I've decided to have a quick go of Ruby, try it out - etc. Most of the tutorials about setting up seem to be very unix/linux orientated and I've not found many straight-forward Windows systems.

    The closest I've found is on this site:
    (http://wiki.rubyonrails.org/rails/pa...for+Windows+XP)

    I've done everything it says, but I'm confused at the bottom, it says that:

    Configure your Rails app

    Go to the public folder in your Rails application and open .htaccess

    Look for the rewrite rule:

    RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

    and change it to:
    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    But as far as I recall Windows doesn't use .htaccess so what is the point of writing one? Also, it refers to a public folder inside Rails applications, but I don't understand what this means?

    I don't want to over-write my apache settings or re-direct document root or serverroot, but I did add a virtual host like it says; plus I created a folder in my htdocs folders called "ruby"

    The "ruby" folder on my htdocs is where I want all my ruby web work to go. I placed a "helloworld.rb" in there and went to localhost/ruby/helloworld.rb but all it does is display the code.

    The helloworld.rb file contains;

    Code:
    puts 'hello world'
    Maybe I'm not getting the point, or I'm missing something - but why can't I just put the code into the ruby folder and let apache do the rest of the work?

    Many thanks.

  2. #2
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by worchyld
    But as far as I recall Windows doesn't use .htaccess so what is the point of writing one?
    You are confusing IIS with Windows, and Apache with Linux.
    Apache is the one using .htaccess files.

  3. #3
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want to try out Rails?
    It very easy: you don't even need apache.

    Follow these steps:

    1. Download the last stable release of the ruby one click installer (includes rubygems package manager):
    http://rubyforge.org/frs/?group_id=167
    and click it twice (^^). follow the installation wizard.

    If you've already installed ruby but NOT rubygems you can
    1. uninstall ruby and reinstall with the one click installer
    2. install rubygems yourself (rubygems is a packagemanager and you'll need it to install rails)

    2. open a console and type:
    gem install rails --include-dependencies [enter]
    cd C:\dev\rails\ [enter] (create this directory if it doesn't exist)
    rails helloworld [enter]
    cd helloworld [enter]
    ruby script/server [enter]

    3. point your browser to http://localhost:3000/. You'll see a welcome screen now.

  4. #4
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll certainly try that -- I thought that Ruby and Ruby on Rails would be a straight switch for Php + Apache + MySQL ... in addition it's likely that most hosts uses Apache; will using the system you suggested cause problems in the future?

    Many thanks.

  5. #5
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yey! After I followed your 1-2-3 step I got the welcome message.

    But I am confused.

    What happens to Ruby/Rails scripts that I make? How do I put them on a real live web server? In php, you write your php code to do something; and you can put it anywhere.

    bonefry -- Apache can be installed under Windows and the web URL that I pointed to gave a tutorial for installing under Apache on a Windows platform, but I got confused right near the end when it started talking about .htaccess, which doesn't work on a windows platform; secondly it kept referring to opening a .htaccess file and changing settings which aren't there.

    I just thought I could put the work into my apache htdocs folder and run it sorta side by side with php whilslt I try to learn a bit of rails.

    I think I will buy that book Agile Web Development with Rails I saw in the shop.

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by worchyld
    yey! After I followed your 1-2-3 step I got the welcome message.

    But I am confused.

    What happens to Ruby/Rails scripts that I make? How do I put them on a real live web server? In php, you write your php code to do something; and you can put it anywhere.

    bonefry -- Apache can be installed under Windows and the web URL that I pointed to gave a tutorial for installing under Apache on a Windows platform, but I got confused right near the end when it started talking about .htaccess, which doesn't work on a windows platform; secondly it kept referring to opening a .htaccess file and changing settings which aren't there.

    I just thought I could put the work into my apache htdocs folder and run it sorta side by side with php whilslt I try to learn a bit of rails.

    I think I will buy that book Agile Web Development with Rails I saw in the shop.
    .htaccess works just fine on Windows because it's not Windows that interprets it, it's Apache. If you install a homemade web server on your Linux box it's not going to read an .htaccess file either. It has absolutely nothing to do with the operating system, it's strictly to do with Apache.

    Off Topic:

    (You didn't see me in the Ruby forum, must've followed a strange link...)

  7. #7
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, so I guess I can just make a .htaccess file and dump it in the directory and it might do something...

    I think I'm mis-understanding some parts. Under the "cmd" when I typed in rails it produced a folder in c:\ruby\ called helloworld with loads of folders.

    Does it matter that the folder "helloworld" is in c:\ruby\? Shouldn't it also be in htdocs too?

  8. #8
    SitePoint Evangelist
    Join Date
    Jun 2004
    Location
    California
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only folder that is "public" is the "public" folder that is generated. THe rest should not be accessible by the web. So you have to setup some sort of symbolic link or so to connect those (public to your web root)

    The rest of the folders are made so you can easily organize and extend your code. Thats what makes rails... fast.

  9. #9
    SitePoint Guru worchyld's Avatar
    Join Date
    Jul 2003
    Location
    Newcastle upon Tyne
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah I see.. I'm looking forward to using it / exploring it further.

  10. #10
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll deploy your applications in a htdocs folder, but development mode of Rails is different. Rails ships with a webserver for development. This webserver is created when you type "rails helloworld": it is in the script folder (script/server). This webserver will point to the application it belongs to. (you've started it with "ruby script/server"). This webserver is great for development, but it is too slow for production. Lighthttpd is recommended, but you can use Apache too. Just copy the entire helloworld folder to your webhost if you want to deploy it. (your host must have ruby/rails support offcourse).
    Rails is diffent: it ships with tools. You have to install the tools yourself if you use PHP, but the tools for Rails are auto-installed to in the helloworld/script directory. Some other tools are in the rake script.

    How to create a simple CMS:
    Create a database helloworld_development (if you give it another name you have to edit the database configuration).
    Create a table posts and give it a title and content.
    Open a console in your helloworld folder and type: "ruby script/generate scaffold posts". Open your browser and load "http://localhost:3000/posts". Enter some posts and check the helloworld/app/(models|controllers|views) files.

  11. #11
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenrir2
    This webserver is great for development, but it is too slow for production.
    Did you know that ./script/server now uses lighttpd instead of WEBrick if you have it installed? It places the lighttpd.conf in your config folder.


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
  •