简体   繁体   中英

How to install Rails application on ubuntu?

While installing, some errors are displayed. The command I am using is:

sudo gem install rails --include-dependencies

or

sudo gem install rails --no-rdoc --no-ri

In both cases, it is the same error. I think my rubygems may not be installed properly?

ERROR: Loading command: install (LoadError) no such file to load -- zlib ERROR: While executing gem ... (NameError) uninitialized constant Gem::Commands::InstallCommand

I have installed ruby-1.9.2-p0 and rubygems-1.3.7

One more thing: Do I have to cd into the ruby or rubygems directory and then install rails or can I do it from default directory?

Open command prompt and please let us know the results

verify Ruby version

ruby -v

verify gem version

gem -v

Use command

gem install rails

verify the rails version

rails -v

Assuming that you are installing on Ubuntu 14.04...

First install rbev to pick a Ruby version for your application.

sudo apt-get update

Install the rbenv and Ruby dependencies with apt-get:

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

Now let's install rbenv

 cd

git clone git://github.com/sstephenson/rbenv.git .rbenv

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile

source ~/.bash_profile

And now let's install Ruby:

rbenv install -v 2.2.3
rbenv global 2.2.3

Verify that Ruby is installed with this command:

ruby -v

Install bundler to manage gems:

gem install bundler

Now we are set to install Rails:

gem install rails

Then run

rbenv rehash

It's good to verify if the Rails is installed properly:

rails -v

Make sure to install database and Javascript runtime afterwards...

$ sudo apt-get install ruby1.9 gem1.9

下面提到的结帐功能可帮助您在ubuntu盒上使用rvm安装rails3 http://www.jaikeerthi.in/2010/11/install-rails-ubuntu/

You have to install zlib1g and zlib1g-dev

sudo aptitude install zlib1g zlib1g-dev

Some GEMs compile some binaries at installation time and need other libraries (such as zlib) be installed on the system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM