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


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

你可能感兴趣的:(subversion)