ROR on OSX

OSX 1.4版自带了ruby语言,这本是件好事可惜apple把它的配置文件搞错了。结果在OSX上安装rails on ruby变成了件无比复杂的事情。 我是参照ROR网站上的方法装的。安装记录如下: 准备工具

  1. Mac OS X 10.4 (也许 10.3)
  2. Xcode 2.4 或更新(this compiles the apps for us)
  3. Willingness to type commands into the Terminal application exactly as they appear here (cut-n-paste works too)
  4. A tasty beverage to enjoy while things compile
Xcode默认是不随OSX安装的,需要在Apple’s Developer Connection下载.文件约800M,安装空间要1.4G以上,默认安装2.4G. Path文件 用TextMate创建login文件。
mate ~/.bash_login
在文件最后添加命令行:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
执行文件:
sh ~/.bash_login
建立安装所需的临时目录:
sudo mkdir -p /usr/local/src sudo chgrp admin /usr/local/src sudo chmod -R 775 /usr/local/src cd /usr/local/src
ruby安装 安装readline:
curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz tar xzvf readline-5.1.tar.gz cd readline-5.1 ./configure --prefix=/usr/local make sudo make install
ruby安装
curl -O ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5-p12.tar.gz tar xzvf ruby-1.8.5-p12.tar.gz cd ruby-1.8.5-p12 ./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local make sudo make install sudo make install-doc cd ..
安装完后输入:ruby -v 应该可以看到:ruby 1.8.5 (2006-12-04 patchlevel 2) [blah] RubyGems安装
curl -O http://rubyforge.rubyuser.de/rubygems/rubygems-0.9.0.tgz tar xzvf rubygems-0.9.0.tgz cd rubygems-0.9.0 sudo /usr/local/bin/ruby setup.rb cd ..
Ruby on Rails安装 sudo gem install rails --include-dependencies Mongrel安装 sudo gem install mongrel --include-dependencies Capistrano sudo gem install capistrano --include-dependencies sudo gem install termios --include-dependencies MySQL
  1. Download the MySQL 5.0 package for OS X PPC or the MySQL 5.0 package for OS X Intel
  2. Double-click the drive image to mount it
  3. Locate the MySQL installer (a file named something like mysql-standard-5.0.27-osx10.4-i686.pkg) and run it, authenticating as needed
  4. Double-click MySQLStartupItem.pkg, authenticate, and let it install
  5. Double-click MySQL.prefPane and install it, deciding whether to make it available to just the current user, or for all system users
MySql本地二进制Gem
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
出现选项:
Select which gem to install for your platform 1. mysql 2.7.3 (mswin32) 2. mysql 2.7.1 (mswin32) 3. mysql 2.7 (ruby) 4. mysql 2.6 (ruby) 5. Skip this gem 6. Cancel installation
选3. 然后会见到些错误:
mysql.c: In function 'Init_mysql': mysql.c:2015: error: 'ulong' undeclared (first use in this function) mysql.c:2015: error: (Each undeclared identifier is reported only once mysql.c:2015: error: for each function it appears in.) mysql.c:2015: error: parse error before numeric constant mysql.c:2018: error: parse error before numeric constant make: *** [mysql.o] Error 1
安装未完成,需要下载个补丁文件:
mkdir -p /usr/local/src/mac-mysql-gem cd /usr/local/src/mac-mysql-gem curl -O http://hivelogic.com/downloads/mac-mysql-gem.patch cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 sudo ruby extconf.rb install mysql -- --with-mysql-dir=/usr/local/mysql sudo cp mysql.c mysql.c.dist sudo patch mysql.c /usr/local/src/mac-mysql-gem/mac-mysql-gem.patch sudo make sudo make install cd /usr/local/src
安装完成
rails testapp cd testapp script/server
如果正常的话应该会看到:
=> Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel available at 0.0.0.0:3000 ** Use CTRL-C to stop.
这时可以打开http://localhost:3000/看看

0 意見:

发表评论