How To Install MacPorts, Apache2, Rails, MySql, Mongrel, and Subversion

本文提供了一套详细的Rails应用程序部署流程,包括安装配置MacPorts、MySQL、Apache2等必要组件,以及设置Ruby环境、安装Rails及依赖Gem的过程。适用于MacMini和MacBookPro平台。
Now that I’m just about ready to deploy my first rails app, I thought I’d get the deployment environment set up rock solid on both the production and the development machines (one Mac Mini and one MacBookPro).

Like many other tutorials on this same subject, your mileage may vary. In fact I’m writing this now, because mine did. After stalling out in many of the tutorials all different places, this is what worked for me.

Download and install MacPorts (used to be DarwinPorts)
Open up a terminal and type:
sudo port selfupdate
making sure everything is the way it should be.
If you’re like me, you get port: command not found in return.
I fixed this by opening up .bash_profile in a text editor (Textmate: mate ~/.bash_profile) and adding the line
export PATH=/opt/local/bin:$PATH
Next download and install MySQL5
I grabbed the binary from the bottom of the MySQL 5 download page. It comes with a System Preference Pane and checkbox for auto-startup. I’m using CocoaSQL for admin.
Change the MySQL5 root password

/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h [HOSTNAME] password 'new-password'
Next load up the Apache2 package
sudo port install apache2
(this takes a while)
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist to launch Apache2 on startup. I’ve disabled Apple’s default Web Sharing in the System Preferences.
Create an initial http.conf file
cd /opt/local/apache2/conf
sudo cp httpd.conf.sample httpd.conf
Start up Apache2
sudo /opt/local/apache2/bin/apachectl -k start
Load up http://localhost. It should say “It works!”

sudo port install fcgi
sudo port install lighttpd +ssl
sudo port install mod_fastcgi
Next load up Subversion package with the mod_dav_svn for Apache2
sudo port install subversion +mod_dav_svn +tools
Next load up Ruby, RubyGems, Termios, RB-MySQL5 Bridge, and ImageMagick Packages
sudo port install ruby
sudo port install rb-rubygems
sudo port install rb-termios
sudo port install rb-fcgi
sudo port install rb-mysql (I had some errors on this one.)
sudo port install imagemagick
Install a bunch of useful gems, like rails and capistrano.

sudo gem install --include-dependencies rake
sudo gem install --include-dependencies rails
sudo gem install --include-dependencies termios
sudo gem install --include-dependencies capistrano


sudo gem install daemons gem_plugin mongrel mongrel_cluster --include-dependencies
sudo gem install --include-dependencies mongrel
sudo gem install --include-dependencies mongrel_cluster


sudo gem install mysql -- \
--with-mysql-dir=/usr/local/mysql \
--with-mysql-include=/usr/local/mysql/include/ \
--with-mysql-lib=/usr/local/mysql/lib/ \
--with-mysql-config=/usr/local/mysql/bin/mysql_config

(thanks to d. robert adams for the last bit)
Create a rails app
rails testapp
Connect the rails app to mongrel

cd /RAILS/ROOT/OF/TESTAPP
mongrel_rails cluster::configure -e development -p 8000 -a 127.0.0.1 -N3 -c /RAILS/ROOT/OF/TESTAPP
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值