How to build a ruby development environment in Ubuntu

Source: Internet
Author: User
Tags install openssl

Ubuntu is a desktop-based Linux operating system that requires the installation of Ruby development in Ubuntu during project development ( http://www.maiziedu.com/course/ruby-px/) language, mainly considering the high variability of the project, and the resulting high adaptability, so choose ruby. Ruby is certainly more flexible than Java , and can write ever-changing code.

But, sadly, it's more problematic to build a ruby environment on top of windows7 . Whether it's based on Cgywinor using NetBeans directly is not as satisfactory.

Because you want to adjust webserver to use nginx+thininstead of Webrick, consider thin the adaptability. Unexpectedly, there are problems with the current ruby1.9.3 p134. Under the project path, each time you run thin start, you will always be prompted intercepter errorat the end,but using webrick is good. Maybe thin and 1.9.3 have not a good combination.

So, switch to Linux under the test environment.

After Jianfengchazhen's efforts, finally saw some hope, set up the thin server.

Let's summarize it for later use. My os is ubuntu12 .

1. Install RVM:

This is relatively simple, directly through the official website (s://rvm.io/rvm/basics/), according to the above instructions can be:

Curl-l Get.rvm.io | Bash-s Stable ( if no Curlis indicated, first sudo apt-get install curl)

Installation completed RVM, there will be a hint, there is said to need SOURCE/HOME/ERIC/.RVM/SCRIPTS/RVM ( here may be different depending on the installation path, different ), you need to take a closer look at the installation completion prompt. If you do not do this, when you run RVM , there will be RVM not a function error prompt.

2. install the RVM Support package:

If you do not install these packages, when running the gem , there will be fewer packets, it is inevitable to reinstall and compile, so take this step forward.

Against RVM 's official website about the package (s://rvm.io/packages/), there are mainly zlib and OpenSSL,zlib

is used by gems , andOpenSSL is used in rails . So, first installed through the official website command:

RVM Pkg Install zlib

RVM Pkg Install OpenSSL

Install Ruby not much to say, directly on:

RVM Install 1.9.2

RVM Install 1.9.3

The two commands above will get the latest build of two versions.

4. set the default Ruby and gemset: (The following will be used to 1.9.2, this version of the time is longer, Some components are more stable)

RVM--default Use 1.9.2

RVM A set of gem management mechanism, that is , gemset, the specific theory is not much to say, you crossing Internet cafes. Some things will be a simple explanation between the commands. Personally, because gems are placed under the gem path of The Ruby compiler, like java 's classpath. So, you should first determine the Ruby version and then create the emset, which is gemset with Ruby the corresponding. How to see which packages are in the Gemset, as well as simply specifying a gemsetandthen running the gem list You can view this Gemset inside the Gem column.

Start managing now Gemset :

Create gemset:rvm gemset Create Gemset_name

then select which one to enable GEMSET:RVM gemset Use Gemset_name ( If you forget that gemset, you can RVM gemset list View )

Once the corresponding gemset is enabled , you can view the gemset path in use through the RVM gemdir , and of course, you can also RVM gemset list , there will be arrows pointing to the gemset being used .

Now you can install various Gem the following: Gem Install Rails

5. After the rails installation is complete, create the project:

Rails New Mytestproj

After the creation is complete, I will use thin and MySQL, so:

CD Mytestproj

VI Gemfile

Comment out sqlite, increase

Gem ' Mysql2 '

Gem ' thin '

Save exit, run:

Bundle Install ( I am running with a hint that MySQL is not installed, so I installed MySQL server and Apt-get Install mysql-client-core-5.5, run this command again ) is running normally.  

6. Test start: rails server thin OK again problem, prompted execjs no JS Run-time error, so sudo apt-get install Nodejs to run again, this time really OK .  

The above is the personal installation process of running water, a page of notes for reference.    

Problem Collection:

1. The following issues occurred when you started the Rails project:

Rails server Thin

/home/eric/.rvm/gems/[email Protected]/gems/mysql2-0.3.11/lib/mysq.rb:9:in

' Reqire ': Libmysqlclient.so.18:cannot Open Shared object file:no such file or directory-

/home/eric/.rvm/gems/[email protected]/gems/mysql2-0.3.11/lib/mysql2/mysql2.so (LoadError) Workaround:

Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib/libmysqlclient.so.18 If you still can't find it, it's probably because your server is 64. for the sake of the bit, do the following:

Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib64/libmysqlclient.so.18

How to build a ruby development environment in Ubuntu

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.