Ruby on Rails Development Environment Construction

Source: Internet
Author: User

Development Environment Construction in Windows

This article describes how to build an RoR development environment in a Windows operating system.

1. Remote Installation

A. Step 1: download and install the Ruby one-click installation package

Download the latest Ruby 1.8.6 one-click installation package for http://rubyforge.org/frs? Group_id = 167.

Download the package and run the installation file. The installation file is displayed on the page 2-1.

  
Figure 1 installation program running interface

Click Next to install it by default. After the installation is complete, open the command line window and enter and run the ruby-v command. After the installation is successful, the Ruby version is displayed, as shown in Figure 2-2.

  
Figure 2 Ruby version information

B. Step 2: Use RubyGems to install Rails

RubyGems is a standard Ruby Package Manager, which features similar to apt-get in Linux. You can use RubyGems to conveniently download and install Rails from a remote server.

Open the command line window, enter and execute the command gem install rails -- remote or gem install rails -- include-dependencies. The program running results are shown in figure 3 and figure 4 respectively.

  
Figure 3 Command Execution

  
Figure 4 Command Execution

Open the command line window and enter and run rails-v. The execution result is 2-5.

  
Figure 5 Rails version information

The displayed Rails version is 1.0.0. After Rails is installed successfully, the RoR development environment is successfully set up.

Note that to install rails using gem install Rails--remote, you can directly download the Rails installation package file from a remote server, and use the gem install rails--include-dependencies command to install Rails, the system first checks whether the Rails installation package exists on the local host. If not, the system downloads and installs the package from the remote server.

2. Local Installation

A. Step 1: download and install the Ruby one-click installation package

For detailed steps, see "Remote Installation.

B. Step 2: Obtain the Rails installation plug-in package

Http://rubyforge.org/frs/ from URL address? Group_id = 307 download rails-2.0.1.gemand rails-2.0.1.zip. Save the downloaded file to the same directory (D:/RoR ).

Note that you do not need to decompress the compressed file.

C. Step 3: Install the Rails plug-in package

Open the command line window, go to the D:/RoR directory, and run the gem install rails command to complete the installation.
 

Build a development environment in Linux

This section describes how to build an RoR development environment in Linux. Although Linux has multiple Release versions, the basic principle and installation process are the same. Here we use the Debian system as an example to describe how to install the RoR development environment in Linux.

A. Step 1: Download the Ruby source code file

Enter and run the wget http://rubyforge.org/frs/download.php/7858/ruby-1.8.4.tar.gz command or your-1.8.4 source code in shell, as shown in 6, the installation file is downloaded to the current directory.

  
Figure 6 process of downloading Ruby installation files

B. Step 2: Install Ruby

To install Ruby, run the following commands in sequence.

1 tar zxvf ruby-1.8.4.tar.gz

2 cd ruby-1.8.4

3./configure-prefix = $ HOME

4 make

5 make install

The execution result of command 1 is to extract the source code file from the compressed package to the ruby-1.8.4 folder in the current directory; the execution result of command 2 is to jump to the ruby-1.8.4 directory; commands 3 to 5 are used to compile and execute source code files. After the preceding five commands are executed, enter and execute the ruby-v command in shell. The result is 7, indicating that Ruby is successfully installed.

  
Figure 7 Ruby version information

C. Step 3: download and install RubyGems

Execute the following commands in sequence to download and install RubyGems.

1 wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz

2 tar xzf rubygems-0.8.11.tgz

3 cd rubygems-0.8.11

4 ruby setup. rb

Command 1 is used to remotely download the RubyGems installation package; command 2 is used for decompression; command 3 is used to jump to the specified directory; command 4 is used to install the RubyGems Package Manager. The preceding four commands are successfully executed, indicating that RubyGems is successfully installed.

D. Step 4: Use RubyGems to install Rails

In the shell, enter and execute the command gem install rails -- include-dependencies to install the Rails framework. After the command is executed, enter rails-v in the shell, if version information is displayed, the RoR development environment is successfully set up.

Installation and configuration of databases in the Development Environment

Here we take MySQL database as an example to introduce the installation and configuration of databases in the development environment.

A. Step 1: download and install the MySQL database

Download and run the installation package for the MySQL database from the http://www.mysql.com, as shown in installation interface 8.

  
Figure 8 MySQL installation page

Install the SDK by default. After the installation is complete, configure the MySQL server instance. Open the MySQL server instance Configuration Wizard at the location shown in Figure 9, as shown in figure 10.

  
Figure 9 shortcut location of the MySQL server instance Configuration Wizard

  
Figure 10 MySQL server instance Configuration Wizard running interface

Install by default. On the page 11, select the Detailed Configuration (Detailed Configuration.

  
Figure 11 configuration mode selection page

Follow the default settings to install on the character set selection page shown in 12. In Figure 12, the Standard Character Set option indicates that the Latin1 Character Set is used as the default Character Set. The content stored in the database only contains English characters and other characters in Western European languages; the Best Support For Multilingualism option indicates that the UTF8 character set is used as the default character set. When this option is selected, the content stored in the database can be composed of characters in multiple languages of different countries; manual Selected Default Character Set/Collation option indicates that you can select the database Character Set as needed. Select the Best Support For Multilingualism option.

  
Figure 12 database character set selection page

Note that you must select Character Set Encoding Based on your actual needs.

In the next installation process, follow the default settings. After the database server instance is configured, MySQL installation is completed.

Note that you can set the Root account password as needed during database server instance configuration. To emphasize the importance, all databases mentioned in this book use a blank password as the Root user password.

B. Step 2: install and configure MySQL-Front

MySQL-Front is a small Mysql management application, its main features include multi-Document Interface, syntax highlighting, drag-and-drop databases and tables, editable/addable/Deleted fields, editable/insertable records, and displayed members. executable SQL scripts, interfaces with external programs, and saving data to CSV files. The MySQL-Front official site http://www.mysqlfront.de provides a 30-day free trial package for MySQL-Front, which is downloaded and run after its initial installation interface 13.

  
Figure 13 initial installation page of MySQL-Front

Use the default configuration for installation. After installation, you must manually associate MySQL-Front with MySQL. The following describes how to associate MySQL-Front with MySQL by taking the instance in Chapter 1st as an example.

When MySQL-Front is opened for the first time, a window shown in 14 is displayed. In the "name" text box, enter the logon description (equivalent to a name for each login). Enter "127.0.0.1" here ".

  
Figure 14 the MySQL-Front pop-up window is opened for the first time.

Switch to the connection tab and enter 127.0.0.1 in the server text box, as shown in Figure 2-15. You can enter the IP address of the MySQL server or the host name. Because the default configuration is used before, other content is not modified here.

  
Figure 15 "connection" tab

Switch to the "register" tab and enter "root" in the "user" text box, as shown in 16. Other content is not modified.

Note that the root user is the default Administrator Account of MySQL. The password is not set in the preceding settings, so the "password" text box is left blank.

  
Figure 16 "register" tab

On the "Data Browser" tab, use the default settings. Click "OK". The dialog startup window is displayed, as shown in figure 17.

  
Figure 17 dialog startup window

Figure 17 shows the dialog we just created. Click OK to bring up the database logon window shown in 18.

  
Figure 18 database logon window

Click OK. The page shown in Figure 19 is displayed. the MySQL database is successfully connected.

  
Figure 19 display page after MySQL-Front connects to the MySQL database

Related Article

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.