`

rails env

阅读更多

1.apt-get安装ruby:
~$ sudo apt-get install ruby rdoc irb libyaml-ruby libzlib-ruby ri libopenssl-ruby ruby1.8-dev build-essential

tongxiaoming520@tongxiaoming520-laptop:/usr/bin$ ls -a | grep ruby   查看ruby的安装目录
ruby -v 查看版本

2.安装Rubygems
将如下代码另存为rubygems.sh

tongxiaoming520@tongxiaoming520-laptop:/usr/bin$ ls -a | grep gem查看gem的安装目录

1. #! /bin/sh
2. wget "http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz"
3. tar -xvzf rubygems-1.3.1.tgz
4. rm rubygems-1.3.1.tgz
5. cd rubygems-1.3.1
6. sudo ruby setup.rb
~$ cd ..
~$ rm -r rubygems-1.3.1
(勿使用 sudo ruby rubygemsx.x.x/setup.rb)
在安装Rubygems之后运行gem命令可能碰到一个错误提示信息,如下:
  $ gem
  程序 'gem' 已包含在以下软件包中:
  * rubygems1.8
  * rubygems1.9
  试试:sudo apt-get install <选定的软件包>
  bash: gem:找不到命令
这是安装程序生成了gem1.8的可执行命令,仔细观察安装最后的一段提示信息可以看到:
   RubyGems installed the following executables:
  /usr/bin/gem1.8
所以此时需要做一个符号链接过去,执行以下命令即可以了:
~$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
~$ gem 此时会正常显示gem的用法
安装之后更新RubyGems:
~$ sudo gem update --system
~$ gem
You don't have /home/tongxiaoming520/.gem/ruby/1.8/bin in your PATH, gem executables will not run.
在/etc/profile
export PATH=/home/tongxiaoming520/.gem/ruby/1.8/bin:$PATH

* 最后,通过Rubygems安装rails:
~$ sudo gem install -v=2.3.2 rails
rails -v  查看版本



~$ sudo gem update --system时失败,可能网速不好 ,等会再试,直到用gem查看到有rubygems-update (1.3.6)
tongxiaoming520@tongxiaoming520-laptop:~$ gem list --local
*** LOCAL GEMS ***
rubygems-update (1.3.6)

~$ sudo gem install -v=2.3.2 rails             gem若没更新成功  ,rails安装会失败
在/etc/profile
export PATH=/home/tongxiaoming520/.gem/ruby/1.8/bin:$PATH




若没安装此包libopenssl-ruby必须安装  tongxiaoming520@tongxiaoming520-laptop:~$ sudo apt-get install libopenssl-ruby


tongxiaoming520@tongxiaoming520-laptop:~/RailsApps/Depot$ rake
(in /home/tongxiaoming520/RailsApps/Depot)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql




tongxiaoming520@tongxiaoming520-laptop:~/RailsApps/test_rails$ script/server                                                                     
=> Booting WEBrick                                                      
=> Rails 2.3.2 application starting on http://0.0.0.0:3000              
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:76:in `establish_connection': Please install the jdbcmysql adapter: `gem install activerecord-jdbcmysql-adapter` (no such file to load -- active_record/connection_adapters/jdbcmysql_adapter) (RuntimeError)

检查这个active_record/connection_adapters/jdbcmysql_adapter是否存在,如果已经安装好再看看这个路径有没有加到环境变量里。

提示安装mysql.rb driver

安装之前必须安装 libmysqlclient15-dev  ruby1.8-dev
sudo apt-get install libmysqlclient15-dev 
sudo apt-get install ruby1.8-dev

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config


===========================================================================================================================
tongxiaoming520@tongxiaoming520-laptop:/usr/local/mysql/bin$ mysql_config --socket
/var/run/mysqld/mysqld.sock
bin/mysql_config --socket

rake db:charset
rake db:version
tongxiaoming520@tongxiaoming520-laptop:~/RailsApps/Depot$ rake --trace db:create:all

===========================================================================================================================

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics