Leopard下手工安装ruby,rails和mysql
by Elton on 八.23, 2009, under Mac, Rails
1. 安装readline
ftp://ftp.gnu.org/gnu/readline/
1 2 3 4 | cd readline-6.0 ./configure --prefix=/usr/local make sudo make install |
2. 安装ruby
1 2 3 4 5 6 | tar xvjf ruby-1.8.7-p174.tar.bz2 cd ruby-1.8.7-p174 ./configure --prefix=/usr/local/ruby --enable-pthread --with-readline-dir=/usr/local --enable-shared make sudo make install sudo make install-doc |
使用ruby -v来确认版本安装正确
3. 安装mysql
1 2 3 4 5 6 | /configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --enable-shared --with-plugins=max-no-ndb make sudo make install cd /usr/local/mysql sudo ./bin/mysql_install_db --user=mysql sudo chown -R mysql ./var/ |
mac os x 是靠 launchd 守护进程运行的, 配置文件用的是 PropertyList (XML 格式), 通过观察发现每10秒检查一次, 发现进程不在就启动.
方法是新建 /Library/LaunchDaemons/com.mysql.mysqld.plist 写入如下内容.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?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 launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist
查看清单
launchctl list
解除守护
sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist
4. 安装mysql的c驱动
http://rubyforge.org/fsr/download.php/51087/mysql-ruby-2.8.1.tar.gz
1 2 3 4 5 | tar xzvf mysql-ruby-2.8.1.tar.gz cd mysql-ruby-2.8.1 ruby extconf.rb --with-mysql-dir=/usr/local/mysql make sudo make instal |
如果出现类似以下的错误
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lmygcc... yes checking for mysql_query() in -lmysqlclient... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. |
就换用
1 | sudo ruby extconf.rb --with-mysql-config |



九月 14th, 2009 on 12:43
Thanks much for that well written piece of text.
六月 7th, 2010 on 04:53
hey i submitted a remark some time back dealing with exactly how to speed up my twilight eclipse website’s loading time because we utilized the very same theme back then and someone placed a comment answering it on my webpage a couple of days ago – if that was you I just wanted to say hi and thanks, and if it was not you then sorry to bother you, but cheers nonetheless! :)
六月 10th, 2010 on 13:38
omg okay so this is how stupid I am, halfway through looking through your post I dropped my sensitive mouse and shut down the site in error and I couldn’t find your site again right up until 6 days later to finish reading through where I left off for the reason that I didn’t remember how I linked to your web site to begin with haha at any rate it was worth the delay..many thanks :)
七月 4th, 2010 on 15:43
Great site. See also
七月 6th, 2010 on 10:32
Thank you! I really appreciate your article, in fact I think you deserve a thumbs up.
七月 11th, 2010 on 00:07
Great blog, I will add this blog to my favorites.
七月 13th, 2010 on 02:57
Great site and nice text.