升级Turnkey Rails虚拟机到最新Rails版本

具体步骤如下:

1.选择用root来安装

2.安装curl

# Install curl. It's needed to install rvm the easy way. Ignore the error about the Java .so:
  apt-get install curl
3. 安装rvm

# Install rvm:(这里bash后面是一个空格,然后<,再一个空格)
  bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)


4. 安装在RVM下Ruby1.9.2

# Install 1.9.2 under rvm:
  rvm install ruby-1.9.2

5. 指定使用1.9.2
# Make it the default:
  rvm use ruby-1.9.2 --default
# Change to it (although the --default line probably does this):
  rvm use ruby-1.9.2-p(patchlevel)

6. 创建gemset
# Gemset for Rails 3:
  rvm gemset create rails3
# Use that gemset:
  rvm gemset use rails3
# (Re-) Install Rails:
  gem install rails
(具体安装版本3.1.0, 会看到一些unable to covert和file 'lib'  not found, 可以忽略)

rails -v 可以看到安装的rails版本

7. 安装Passenger(RoR的部署技术)

# (Re-) Install Passenger:
  gem install passenger
# Install the necessary prerequisite library:
  apt-get install libcurl4-openssl-dev
 
Compile and install the Passenger module. First you have to find the version of Passenger that you just installed (which is in a different place from the one preinstalled in the appliance):
  find /usr/local/rvm -name passenger-install-apache2-module
 
Two paths will appear, one of them in bin and the other one in gems. Take the shorter one and copy it. For my system, the two paths were:
  /usr/local/rvm/gems/ruby-1.9.2-p290@rails3/bin/passenger-install-apache2-module
  and
  /usr/local/rvm/gems/ruby-1.9.2-p290@rails3/gems/passenger-3.0.8/bin/passenger-install-apache2-module
 
Run that script:
/usr/local/rvm/gems/ruby-1.9.2-p290@rails3/bin/passenger-install-apache2-module
 
IMPORTANT: Grab the configuration lines at the end of the passenger install process! If you just use the default Passenger LoadModule, PassengerRoot, and PassengerRuby lines the GEM_HOME and paths won't be set up correctly, and you'll run into issues like "bundler: cannot load file". For my system, those lines were:
  LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.2-p290@rails3/gems/passenger-3.0.9/ext/apache2/mod_passenger.so
  PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p290@rails3/gems/passenger-3.0.9
  PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.2-p290@rails3/ruby
 
In /etc/apache2/conf.d/passenger, replace the three corresponding lines with the new stuff you copied.
 
8. 安装Node.js (不安装Rails 3.1会报这个错误 Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable))

apt-get install Python-software-properties
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get install nodejs

Set up your Rails application in /var/www/railsapp, do a bundle install, restart Apache (/etc/init.d/apache2 restart), and you're golden!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://127.0.0.1/wyygsz.html