Mac 下基于ruby 1.9安装Rails

Posted by Elton's Blog on May 24, 2009

ruby 1.9.1出来了,今天用它安装了rails。 一次成功, 将过程记录下来,备忘。


源码安装Ruby ************* tar xvzf ruby-1.9.1-p0.tar.gz cd ruby-1.9.1

./configure –enable-shared –enable-pthread CFLAGS=-D_XOPEN_SOURCE=1

make sudo make install


安装Ruby ************* sudo gem install rails

升级gem sudo gem update –system


安装Ruby for sqlite3 ************* sudo gem install sqlite3-ruby


源码安装MySQL ************* tar xvzf mysql-5.1.34.tar.gz cd mysql-5.1.34.tar.gz

CC=gcc CFLAGS=”-O3 -fno-omit-frame-pointer” CXX=gcc CXXFLAGS=”-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti” ./configure –prefix=/usr/local/mysql –with-extra-charsets=complex –enable-thread-safe-client –enable-local-infile –disable-shared –with-plugins=innobase

make sudo make install

cd /usr/local/mysql sudo ./bin/mysql_install_db –user=mysql sudo chown -R mysql ./var/ sudo chgrp -R mysql .

cd /Library/LaunchDaemons sudo vim com.mysql.mysqld.plist 输入

<?xml version=”1.0” encoding=”UTF-8”?> <!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”> <plist version=”1.0”> <dict> <key>KeepAlive</key> <true/> <key>Label</key> <string>com.mysql.mysqld</string> <key>Program</key> <string>/usr/local/mysql/bin/mysqld_safe</string> <key>RunAtLoad</key> <true/> <key>UserName</key> <string>mysql</string> <key>WorkingDirectory</key> <string>/usr/local/mysql</string> </dict> </plist>

sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist

启动MySQL sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist

手工停止MySQL sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist


设置路径 ************* mate ~/.bash_login 或者 mate ~/.profile

添加: export PATH=”/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH”

为了使其生效, 执行 . ~/.bash_login 或者 . ~/.profile


源码安装MySQL C Binding for Ruby *************

tar xvzf mysql-ruby-2.8.1 cd mysql-ruby-2.8.1 ruby extconf.rb –with-mysql-config=/usr/local/mysql/bin/mysql_config -with-mysql-dir=/usr/local/mysql make sudo make install