Build a Ruby on Rails environment on CentOS 5.9

Source: Internet
Author: User

Build a Ruby on Rails environment on CentOS 5.9

1. Step 1

Su root ***

# Install dependency packages
Yum-y install gcc

Yum install flex autoconf zlib curl zlib-devel curl-devel bzip2 bzip2-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel

Gcc + gcc-c ++ libxml2 libxml2-devel libxslt-devel

(Note: all the preceding packages must be installed. Otherwise, an error occurs in the rails environment)

2. Step 2

# Installing RVM
Bash-s stable <(curl-s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

3. Step 3

# Install ruby
# Display available Installation
[Root @ localhost ~] # Rvm list known # MRI Rubies
.. [Ruby-] 1.8.7 [-p334] [ruby-] 1.8.7-head
.. [Ruby-] 1.9.2 [-p180] [ruby-] 1.9.2-head
.. [Ruby-] 1.9.3 [-p448] ruby-head # JRuby jruby-1.2.0
.. [Root @ localhost ~] # Rvm install 1.9.3-p448 // This version is most compatible with rails and other later Aptana environments, and is relatively stable.
# Set to use this version
[Root @ localhost ~] # Rvm use install 1.9.3-p448 -- default
[Root @ localhost ~] # Ruby-v // display ruby version
4. Step 4

# Install several gem dependent packages
Rvm install ree rvm pkg install readline rvm pkg install zlib rvm pkg install openssl
5. Step 5

# Modifying source http://ruby.taobao.org/

Gem sources-l gem sources -- remove the source to be deleted (the source shown above)
Gem sources-a http://ruby.taobao.org/gem sources-l // modified source

** Current sources ***
Http://ruby.taobao.org/

Gem install foo
6. Step 6

# Installing rails
Gem install rails-v = 3.1.0 rails-v // display the version of rails
In this way, ruby on rails can be set up!
7. Step 7

To build Aptana Studio, you must run it in the java environment. First, install the java environment and install jdk on Centos 5.9 64-bit. 1.) download
Download the installation package http://www.Oracle.com from the official website ..

Because it is a 64-bit system, so here we choose jdk-7u17-linux-x64.rpm

2) install only as root users
[Root @ Master Download] # sudo rpm-ivh jdk-7u17-linux-x64.rpm
3) Configure Environment Variables
Modify the/etc/profile file and add the following code.
# Set java environment export JAVA_HOME =/usr/java/jdk1.7.0 _ 17 export CLASSPATH =.: $ JAVA_HOME/jre/lib/rt. jar: $ JAVA_HOME/lib/dt. jar: \ $ JAVA_HOME/lib/tools. jar
Export PATH = $ PATH: $ JAVA_HOME/bin

Make the configuration take effect
[Root @ Master Download] # source/etc/profile
4) Confirm Installation
Run java-version to view the jdk version.
[Root @ Master Download] # java-version java version "1.7.0 _ 17" Java (TM) SE Runtime Environment (build 1.7.0 _ 17-b02)
Java HotSpot (TM) 64-Bit Server VM (build 23.7-b01, mixed mode) jdk installation is complete.

8. Step 8: Build Aptana Studio 3

Install aptana3 in linux.
The following describes how to install aptana3 (aptana2 should also be used ).

When installing the java runtime, you can see that this step is not actually performed, because you have installed java before installing aptana3.
Upload aptana3 to the official aptana website. The compressed package I downloaded is Aptana_Studio_3_Setup_Linux_x86_3.0.0.
Decompress the package to obtain the folder Aptana Studio 3. We recommend that you rename it AptanaStudio3.

Now, assume that the path of your AptanaStudio3 is/home/yourname/Downloads/AptanaStudio3. Here we will consider where to place AptanaStudio3 ~~

Enter the/opt folder on the terminal, create a directory named aptana, move AptanaStudio3 to aptana, and add the root permission.

$ Cd/opt $ sudo mkdir aptana $ sudo chown-R root: root aptana $ sudo chmod-R + r aptana $ cd aptana $ sudo mv/home/yourname/Downloads/AptanaStudio3.
$ Sudo chown-R root: root AptanaStudio3

$ Sudo chmod-R + r AptanaStudio3

Create an executable file for aptana (similar to the concept of exe in windows)
$ Touch/usr/bin/aptana $ chmod 755/usr/bin/aptana $ nano/usr/bin/aptana
In this case, nano will open an editor, add the following code to the nano editor, and save it:
#! /Bin/sh # export illa_five_home = "/usr/lib/mozilla/" export APTANA_HOME = "/opt/aptana/AptanaStudio3" $ APTANA_HOME/AptanaStudio3 $ *
Add the aptana Startup menu under the Applications menu in the upper left corner.
$ Nano/usr/share/applications/aptana. desktop inserts the following code in the editor and saves [Desktop Entry] Encoding = UTF-8 Name = Aptana Studio 3 Comment = IDE for Rails, Python, PHPExec =/opt/aptana/AptanaStudio3/AptanaStudio3 // you must enter the correct Icon in the Path =/opt/aptana/AptanaStudio3/icon. xpm Terminal = false Type = ApplicationCategories = GNOME; Application; Development;
StartupNotify = true

Initialize and start aptana3.
$/Opt/aptana/AptanaStudio3/AptanaStudio3-clean: Aptana Studio is ready!
Finally, when you inject a set of development kits into Aptana, a bug will occur. I use google to solve the following: First, solve the problem that mysql2 cannot be installed.
Error installing mysql2: Failed to build gem native extension
On Ubuntu/Debian and other distributions using aptitude: sudo apt-get install libmysql-ruby libmysqlclient-dev On Red Hat/CentOS and other distributions using yum: sudo yum install mysql-devel On Mac OS X with Homebrew: brew install mysql
Then solve the bug of Aptana Studio 3 keeps reporting cocould not find mysql2-0.3.11 in any of the sources (Bundler: GemNotFound)

Well, after I tried everything, I found out that the answer is as simple as: bundle install -- deployment (on the server) Note !!!
Then Aptana Studio will run normally!
I have learned a lot in installing ruby on rails. I hope this article will be helpful for installing such environments in the future!

Related reading:

Build Ruby On Rails in Ubuntu

Build Ruby on Rails on Ubuntu 13.10

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.