环境:CentOS 6.6
ruby是开发语音,rails是开发框架,例如:DoitPHP是PHP的开发框架一样
官网安装方式:http://rubyonrails.org/download/
[[email protected] ~]# yum -y groupinstall "Development Tools" [[email protected] ~]# yum -y install libyaml* ruby-devel [[email protected] software]# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.gz
[[email protected] software]# tar -zxvf ruby-1.9.3-p448.tar.gz [[email protected] software]# cd ruby-1.9.3-p448 [[email protected] ruby-1.9.3-p448]# ./configure --prefix=/usr/local/ruby [[email protected] ruby-1.9.3-p448]# make [[email protected] ruby-1.9.3-p448]# make install [[email protected] ~]# tail -1 /etc/profile export PATH=/usr/local/ruby/bin:$PATH [[email protected] ~]# ruby -v ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux] [[email protected] ~]#
[[email protected] software]# tar -zxvf rubygems-1.8.24.tgz [[email protected] software]# cd rubygems-1.8.24 [[email protected] rubygems-1.8.24]# ruby setup.rb [[email protected] ~]# gem -v 1.8.24 [[email protected] ~]#
[[email protected] ~]# yum -y install zlib zlib-devel [[email protected] ~]# cd /software/ruby-1.9.3-p448/ext/zlib/
[[email protected] zlib]# ruby ./extconf.rb [[email protected] zlib]# make &&make install
更换gem源
[[email protected] ~]# gem sources list /usr/local/ruby/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. *** CURRENT SOURCES *** http://rubygems.org/ [[email protected] ~]# gem sources --remove http://rubygems.org/
[[email protected] ~]# yum -y install openssl openssl-devel [[email protected] ~]# cd /software/ruby-1.9.3-p448/ext/openssl/ [[email protected] openssl]# ruby extconf.rb
#make时报下面的错误:
修改ossl_pkey_ec.c文件,因为:由redhat新版本默认openssl的配置变更取消了对EC_xx的支持,所以出现该错误
再次执行就OK了
[[email protected] openssl]# make && make install
添加新的gem源:
[[email protected] openssl]# gem sources -a https://ruby.taobao.org/ [[email protected] ~]# gem sources list /usr/local/ruby/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>': It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. *** CURRENT SOURCES *** https://ruby.taobao.org/ [[email protected] ~]#
[[email protected] ~]# gem install rdoc [[email protected] ~]# gem install bundle [[email protected] ~]# gem install spring [[email protected] ~]# gem install rails //很慢。。 [[email protected] ~]# rails -v Rails 4.2.5 [[email protected] ~]#
[[email protected] ~]# gem install rake -v '10.4.2' [[email protected] ~]# yum -y install sqlite-devel [[email protected] ~]# gem install sqlite3
新建一个项目:
[[email protected] ~]# rails new HelloWorld
这时会因为环境原因而导致创建失败,可以通过bundle install执行解决
[[email protected] ~]# cd HelloWorld/ [[email protected] HelloWorld]# head -1 Gemfile source 'https://ruby.taobao.org/' [[email protected] HelloWorld]# [[email protected] HelloWorld]# bundle install -V [[email protected] ~]# rails new HelloWorld
[[email protected] ~]# cd HelloWorld/ [[email protected] HelloWorld]# rails server //如果执行报错,需要升级rubygems版本 [[email protected] ~]# gem install rubygems-update [[email protected] ~]# update_rubygems [[email protected] ~]# gem -v 2.5.0 [[email protected] ~]#
再次执行rails server报下面的错误
[[email protected] HelloWorld]# grep therubyracer Gemfile |grep -v ^# gem 'therubyracer' [[email protected] HelloWorld]# bundle install -V [[email protected] HelloWorld]# rails server -b 172.24.17.120 -p 2000 -d Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring. => Booting WEBrick => Rails 4.2.5 application starting in development on http://172.24.17.120:2000 => Run `rails server -h` for more startup options [[email protected] HelloWorld]# [[email protected] ~]# netstat -tunlp|grep 2000 tcp 0 0 172.24.17.120:2000 0.0.0.0:* LISTEN 21417/ruby [[email protected] ~]#
视频:Ruby在Linux下搭建Ruby On Rails开发环境:
http://v.youku.com/v_show/id_XMzk2MDI5MDMy.html
请发表评论