Mac OS X - ideal development platform - VMware, Ruby on Rails & Ubuntu
Mac as the ideal development platform? Maybe for the iPhone I hear you mumble. Until I found this nice, clean and extremely flexible solution I wholeheartedly agreed. The basic scheme goes like this:
As foundation I am now running a clean, basically stock OS X. On top of this I am running a bunch of VMware Fusion Virtual machines, ranging from OS X, Ubuntu down to Windows XP ;-). Basically I am running all the development environment in Ubuntu and doing all the research and editing on OS X natively.
To achieve this I have a Ubuntu Server 8.10 with PostgreSQL, Apache 2 prefork, Ruby Enterprise Edition and Rails 2.2.2 installed. This Linux VM shares my Mac OS X Project folder via VMware HGFS mount directly in /var/www/projectname. This setup enables me to work with Textmate and save/copy/mess around locally on my Mac OS X host system (10.5.6) and immediately have the changes reflected in the Ubuntu machine. So the basic workflow is the same than before with having RoR etc. installed locally on my OS X. Hope I made myself clear!?
Here is how to get there (you may have to adjust the version numbers and replace cabchap&tom with the required domain/user):
- Install Ubuntu Intrepid Ibex Server CD, using F4 - minimal system, then press “Install” and later select “Basic Ubuntu Server”, “SSH Server” and “PostgreSQL Server”.
- sudo apt-get update -o Acquire::http::No-Cache=True
- sudo apt-get dist-upgrade
- sudo apt-get install build-essential zlib1g-dev libssl-dev libpq-dev apache2-mpm-prefork apache2-prefork-dev libreadline5-dev git-core
- wget http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz
- tar xvfz ruby-enterprise-1.8.6-20081215.tar.gz
- cd ruby-enterprise-1.8.6-20081215/
- sudo ./installer
- sudo ln -s /opt/ruby-enterprise-1.8.6-20081215/ /opt/ruby-enterprise
- sudo ln -s /opt/ruby-enterprise/bin/gem /usr/bin/gem
- sudo ln -s /opt/ruby-enterprise/bin/ruby /usr/bin/ruby
- sudo ln -s /opt/ruby-enterprise/bin/rake /usr/bin/rake
- sudo ln -s /opt/ruby-enterprise/bin/irb /usr/bin/irb
- sudo ln -s /opt/ruby-enterprise/bin/rails /usr/bin/rails
- sudo /opt/ruby-enterprise-1.8.6-20081215/bin/passenger-install-apache2-module
- sudo vi /etc/apache2/httpd.conf [and enter the following:]
# General stuff
ServerSignature Off
LogLevel warn
# Set Rails mode
RailsEnv development
# Lock down GIT files
<Files ~ “^\.git”>
Order allow,deny
Deny from all
</Files>
# Prepare for Rails
LoadModule passenger_module /opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.6-20081215/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /opt/ruby-enterprise-1.8.6-20081215/bin/ruby - cd /etc/apache2/sites-available/
- cp default default.orig
- sudo vi /etc/apache2/sites-available/default [fill only with:]
<VirtualHost *>
ServerName dev.cabchap.com
ServerAdmin devmaster@cabchap.com
DocumentRoot /var/www/cabchap/public
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost> - cd /var/www
- sudo mkdir cabchap
- sudo chown tom cabchap
- rails -d postgresql cabchap
- sudo -u postgres createuser cabchap [answer yes to superuser]
- sudo vi /etc/postgresql/8.3/main/pg_hba.conf
host all all 192.168.0.0/16 md5
Replace:
local all all ident sameuser
with this line:
local all all md5 - sudo vi /etc/postgresql/8.3/main/postgresql.conf
listen_addresses=’*’ - sudo /etc/init.d/postgresql-8.3 restart
- sudo /etc/init.d/apache2 restart
- Finally configure the VMware shared folder in VMware settings for the relevant machine:
- Name: cabchap (this name is mounted in fstab)
- Folder: dev (in Projects/Something/dev)
- In etc/fstab enter
.host:/ /mnt/hgfs vmhgfs defaults,user,ttl=5,uid=tom,gid=tom 0 0
Let me know if this interesting for someone out there. If it is, I will invest more time in clarifying these quick draft notes. May this be helpful.