Welcome To Grape Thinking!

Grape Thinking has much to offer for everyone, from the casual wine drinker to the wine-makers themselves. more...

We've recently renovated our site, and would love to hear your feedback --> here

Tastevine.com
Check out Tastevine.com for great wine recommendations.

  • Getting Rails to Work on a Windows Machine Running Xampp

    Wow… so I wrote a post on my struggles getting Rails to work on my Windows Machine, and then I figure it out. I’ve been developing in various languages, and using Xampp to for my server, database, and programming language (Apache, MySQL, PHP). Nevertheless, I have finally got it working, and it was a lot simpler than I had figured. In case you’ve come here and you’re yet to get Xampp… I’ll walk you through the whole process. If you already have it, then go ahead and skip to STEP 2

    STEP 1 - Install Xampp - ApacheFriends has made it really easy by giving us a simple windows installer to download. If your interested in developing with Perl, Tomcat, you can download their Add-Ons by clicking the links. Once you download, just give it a click and follow the on-screen instructions. I recommend you install Xampp at the default c:\xampp (if you do not, remember to replace the code below with your installation directory). Here’s a video to show you how simple it is…don’t be fooled, it takes a little longer than the video shows.


    STEP 2 - Install Ruby - Thanks to RubyForge, you can download an easy one-click Ruby installer to use here. Once you download, click to open, and follow the instructions. I recommend you install Ruby at c:\xampp\ruby so it falls in line with your other programming languages, etc…

    STEP 3 - Install Rails - Fortunately, the Windows version of Ruby comes with RubyGems already set up. Open your Command Prompt (start-> run-> cmd -OR- start-> programs-> accessories -> command prompt) and type the following commands.

    Do the gem update from the bin directory in rails. For my installation:

    cd c:\ruby\bin
    gem update
    You may be prompted several times to choose which gem. Pick the highest version for (mswin32)
    gem install rails --include-dependencies

    There may be some delays, and the install could take a while. If you encounter an error trying to use the gem command, just restart the Command Prompt.

    STEP 4 - Create a Rails App - While your still in Command Prompt, type the following Command (without the brackets, and change “your-app-name” to whatever you wish to call your application)

    rails C:/xampp/htdocs/<your-app-name>

    STEP 5 - Configure Apache - With your Xampp installation, http://localhost (localhost:80) defaults to the Xampp browser control panel, which displays your status, tests, etc.. We want to be able to use Ruby, without disrupting this service, or interfering with our standard Xampp settings. Open your Xampp directory (in our case C:\Xampp) and browse to Apache\conf\httpd.conf and open the httpd.conf file in a text editor or other text editor of your choice.

    Scroll all the way to the bottom, and add the following:

    Listen 3000
    LoadModule rewrite_module modules/mod_rewrite.so
    #################################
    # RUBY SETUP
    #################################
    <virtualHost *:3000>
    ServerName rails

    DocumentRoot "c:/xampp/htdocs/<your-app-name>/public"
    <Directory "c:/xampp/htdocs/<your-app-name>/public/">

    Options ExecCGI FollowSymLinks
    AllowOverride all
    Allow from all
    Order allow,deny
    AddHandler cgi-script .cgi
    AddHandler fastcgi-script .fcgi

    </Directory>
    </VirtualHost>

    #################################
    # RUBY SETUP
    #################################

    Finally - Check it Out - Point your browser to http://localhost:3000 and you should see the “Welcome Aboard” from ROR.

    If your also looking for some editors. A nice simple free PHP editor with great extensions is “PSPad“. For hardcore coding, I recommend Zend(free for 30 days). For a nice simple free Rails Editor, “RoRED“, something a little more intense I would say go with the free “NetBeans” (don’t forget the .jdk).


    Tags: , , , , ,

    Comments

    1. Installing Ubuntu and Rails on Virtual PC 2007 | Grape Thinking Said,

      […] I finally got it working on Windows - check it out)[…]

    2. Jake Said,

      Some comments for this post started popping up in a thread on another post.. if your having any problems you might want to also check here

    3. hafreze Said,

      thanks for the guideline..have some troubles while installing ruby with xampp..

    4. hafreze Said,

      a problem occured, after I add the the syntax in httpd.conf, and I restart the apache, it cannot runs well. then, i remove the syntax, apache runs well. how to solve it?

    5. Jake Said,

      Sorry hafreze… I just went back over everything… there was a missing “>” at the end of the Directory line… /public/”>

      If you copy and paste the info now, everything should work fine for you!

    6. Geshan Said,

      I got it working but am stuck in database selection with production, dev and test. I found one small mis-pointer in your blog post :

      “Open your Xampp directory (in our case C:\Xampp) and browse to Apache -> httpd.conf and open the httpd.conf file in a text editor or other program editor of your choice.”

      its should be \xampp_folder\apache\conf\httpd.conf file.

      Geshan

    7. jake Said,

      @Geshan.. thanks for pointing that out… I’ll be sure to update the post.

      If you are running Xampp, then you want to make sure you set the rails config for mysql database. You want multiple databases for prod. dev., and test… I just created for my 3.

    8. hafreze Said,

      after all, the configuration for rails in xampp is working..thanks jake. By the way, as what Geshan had stated, the default database for rails is sqllite3. I would like to use the mysql in xampp as my database, is it possible to do that?

    9. Jake Said,

      @hafreze

      Yes, in the new Ruby, its as easier as changing adapter: sqlite to adapter: mysql in the config/database.yml

    10. hafreze Said,

      oh really?!..I read at other forum in which they stated about the usage of socket..is it necessary? MYSQL_SOCKET_LOCATIONS = [ ”/tmp/mysql.sock”, #default ”/var/run/mysqld/mysqld.sock”, #debian/gentoo ”/var/tmp/mysql.sock”, # freebsd ”/opt/lampp/var/mysql/mysql.sock”, # xampp ”/var/lib/mysql/mysql.sock” , #fedora ”/Applications/xampp/xamppfiles/var/mysql/mysql.sock”] #xampp on osx

      if needed, how could i correctly configure that?

    11. hafreze Said,

      ok..i figure out on how to change from sqllite 3 to mysql..we should change the config/database.yml file

      # SQLite version 3.x
      # gem install sqlite3-ruby (not necessary on OS X Leopard)
      development:
      adapter: mysql
      encoding: utf8
      database: temp_development
      username: root
      password:
      socket: /tmp/mysql.sock

      # Warning: The database defined as ‘test’ will be erased and
      # re-generated from your development database when you run ‘rake’.
      # Do not set this db to the same as development or production.
      test:
      adapter: mysql
      encoding: utf8
      database: temp_test
      username: root
      password:
      socket: /tmp/mysql.sock

      production:
      adapter: mysql
      encoding: utf8
      database: temp_production
      username: root
      password:
      socket: /tmp/mysql.sock

      after that, go to phpmyadmin and create database with the name of ‘temp_development’

    Add A Comment

    Contact Us |  RSS
    millennial marketing