Ruby on Rails + MySQL Development Environment setup

Source: Internet
Author: User
Tags mysql download ruby on rails

Ror may be the biggest difficulty for beginners, that is, the installation and setup of the development environment. Today, it has been around for a long time, and the process has been posted here, so that beginners can avoid detours.

1. Install Ruby 1.8.6

Open http://rubyforge.org/frs? Group_id = 167, install the final version of ruby1.8.6-26

After the download is complete, enter the ruby-V verification version in the command line: \ Ruby \ bin is added to the PATH environment variable)

Note: After this step is completed, you can experience the ruby language on the local machine. By default, the installer will install a ruby editor scite.

As a free editor that is lightweight, flexible, and supports highlighting syntax while displaying running results, this is suitable for beginners. (the code is written and saved. run f5)

 

2. Install rails. Enter gem install rails in the command line.

I don't know why. The following error is always prompted on my machine (Windows 2008 SP2:

The same is true for disabling the firewall. It seems that it is not the reason for the network speed. In desperation, download another version (still on the download page just now ):
 

After the installation is complete, run the gem install rails command again. (However, this process requires online download for a long time.) After the installation is complete, enter the rails-V command line to verify the version.


3. Install mongrel (equivalent to IIS In Asp.net development. I have seen on the Internet that ROR can be run on IIS, but I have never tried it)
Command Line: Gem install mongrel (for more mongrel operations, refer to this article: http://hi.baidu.com/camark/blog/item/10958516dce12d52f3de32c9.html)


4. Create a test rails project:

Command Line: rails c: \ work \ hello

This command will create a test project Hello under the c: \ work directory

Run the following command to test the project ):

C :\

CD \ work \ hello

Mongrel_rails start-d

After successful, the mongrel server listens to HTTP requests on port 3000 of the Local Machine and tries to access http: // localhost: 3000/. If the following picture is displayed, the rails environment is basically OK.

Here we can see that the rails project uses SQLite as the database by default. Click "about your application's environment" to display the following information:

If this information cannot be displayed on your machine, most of them are the sqlite3.dll files not in the C: \ Ruby \ bin directory (which can be in the http://rubyforge.org/frs? Group_id = 904 download instantrails-2.0-win.zip and decompress it). Of course, if you want to use MySQL as the database, continue to read it.

 

5. Install MySQL

5.1 Baidu "MySQL download" the first one is: Baidu

Tip: it is best to Install Version 4.1 or 5.0. Do not install the latest version 5.1. The rails framework does not support MySQL 5.1 well. An error is always prompted during rake DB: migrate.

5.2 find a suitable MySQL management tool. If you are a PHP programmer, phpmysqladmin may be very suitable for you. If you only like IIS like me, there is no PHP environment on the machine, sqlyog enterprise will be a good choice (we can find the "Special Edition" in a moment, huh)

 

6. Configure MySQL connection under Ruby

6.1 copy libmysql. dll in the bin directory of the MySQL installation directory to the bin directory of the Ruby installation directory (generally C: \ Ruby \ binUnder)

6.2 To http://rubyforge.org/frs? Group_id = 627 download rdoc-2.4.3.gem (Note: Only under thunder, directly Save As, file suffix will become non. then copy the rdoc-2.4.3.gem to c: \ Ruby \ down (the down directory is built by myself), and then run the command line:

Cd c: \ Ruby \ down

Gem install rdoc-2.4.3.gem

This is to facilitate the subsequent installation of MySQL for Ruby documents.

6.3 install the MySQL for Ruby driver and run the following command: Gem install MySQL

6.4 copy mysql. So to c: \ Ruby \ Lib \ Ruby \ site_ruby \ 1.8 \ i386-msvcrt (if the mysql. So file cannot be found on the local machine, can be in the http://rubyforge.org/frs? Group_id = 904 download instantrails-2.0-win.zip and decompress it)

Then you can connect to the node in the Code:

Okay, basically. Enjoy ror. (Reprinted please indicate from [under the bodhi tree Yang Guo] http://www.cnblogs.com/yjmyzz/archive/2010/02/18/1669137.html)

For other questions, see the setup of the rails runtime environment by Mr. Situ zhengmei.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.