Setting Up a Development Environment in Mac OS X

I work at a web agency called Domain7 in Abbotsford, BC, Canada. It’s a fun group of people to work with. I’m about a decade older than most of them. It helps keep my young. Domain7 has a suite of tools that the owner, Shawn Neumann has been developing for the last ten years, called RouteOne. The application and its components are written in Perl and developed in a Linux environment. Perl is a language that I have very little experience with. I once played around with MovableType. That’s about it.

I have been doing interface design for the Project Manager module of the system, and we have it to the point that our entire team has been using it to track time for Projects and Tickets. I like to be able to understand how the system works so I can add functionality in a way that works. To be able to help with the development of the application, I want to learn a little Perl to help me understand our templating system better. Also, I have some ideas about how we might be able to make things better by using XSLT as a templating engine for the system. I’m a big fan of open source and web standards, plus my experience with a web publishing application called Symphony has sold me on the idea of using XSLT to develop a much more flexible system for managing content.


To that end, I wanted to set up a development environment for working on RouteOne, our suite of proprietary web tools and modules. To accomplish this, I needed Apache, MySQL, Perl and an Eclipse-based IDE with CVS support. Here are the steps I took to set up my system.

I started with a fresh install of Mac OS X 10.5.3 on my Power Mac G5 booting off an external LaCie Firewire drive. This allows me to have a portable system, separate from the system I use for home use.

Hardware Overview

Model Name:            Power Mac G5
Model Identifier:      PowerMac7,3
Processor Name:        PowerPC G5 (3.0)
Processor Speed:       2 GHz
Number Of CPUs:        2
L2 Cache (per CPU):    512 KB
Memory:                2 GB
Bus Speed:             1 GHz
Boot ROM Version:      5.2.4f1

System Software Overview

System Version:        Mac OS X 10.5.3 (9D34)
Kernel Version:        Darwin 9.3.0

Mac OS X Software

To start with, I don’t need a whole lot as far as software goes. I can generally find free software for everything that I might want to do. I recommend the following if you want to go the free/open source route:

Free/Open Source Tools

  • Firefox – web browser
  • Firebug – an indispensable Firefox web developer plugin
  • TextWrangler – text editor
  • AptanaStudio – a nice open source IDE (integrated development environment)
  • Cyberduck – FTP/SFTP client
  • MAMP – Apache, MySQL and PHP for Mac OS X
  • Symphony – a web publishing system based on PHP, XML and XSLT

Commercial Tools

Panic produces two of what have become my favourite tools for web development. Also, Adobe Creative Suite 3 rounds out requirements as a graphic designer/web developer.

  • Transmit – FTP/SFTP client
  • Coda – text editor, FTP client, terminal, css editor, browser
  • Adobe Creative Suite – Illustrator, Photoshop – graphics and image editing

Installation Procedure

The system I needed to set up required several Perl modules to be installed, in addition to Apache and MySQL. I decided, based on previous experience, that I was going to avoid using CPAN to install Perl modules as much as possible. I found that using MacPorts was much faster by far, and less prone to additional user input and errors resulting from missing dependencies.

Install MacPorts

According to the MacPorts website:

The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac OS X operating system. To that end we provide the command-line driven MacPorts software package under a BSD License, and through it easy access to thousands of ports that greatly simplify the task of compiling and installing open-source software on your Mac.

Before installing MacPorts, it is required to install Apple’s XCode Developer Tools and X11. This software is included on the install disks for the Mac. However, the latest version of XCode is available for download from the Apple Developer Connection.

Download the appropriate MacPorts package installer. Run the package installer. When installed, open Terminal and run the following command to update MacPorts to the latest version:

	sudo port -v selfupdate

Install MySQL

Review instructions for upgrading/installing MySQL

Marc Liyanage provides a good set of instructions for installing and upgrading MySQL. Download latest version of the Mac OS X package installer for MySQL 5.0. Install MySQL by running the installer:


Install MySQL Startup Item by running the installer:


Install MySQL.prefPane:


Add aliases to .profile. (By the way, I am using TextWrangler here with the command line tools installed so that when I type edit filename, this will automatically open the file filename in TextWrangler for editing. One of the things I like about TextWrangler is its integration with Terminal in Mac OS X. As an alternative, use nano to edit this file. It will not be visible in the Finder because any file that starts with a . is a hidden file in the Finder. Use Terminal or an application such as TextWrangler, Transmit or Coda which can be enabled to view hidden or invisible files.)

	cd ~
	edit .profile

Add the following to the .profile

	alias mysql=/usr/local/mysql/bin/mysql
	alias mysqladmin=/usr/local/mysql/bin/mysqladmin

Start up MySQL server:

	sudo /usr/local/mysql/bin/mysqld_safe

Login to MySQL monitor

	mysql -u root

Verify that MySQL server 5.0.51b is installed. Upon typing the above command in Terminal, you should receive a message similar to the welcome message below. You may want to follow the recommended instructions to change the root password and set up a new user.

	Welcome to the MySQL monitor.  Commands end with ; or \g.
	Your MySQL connection id is 1
	Server version: 5.0.51b MySQL Community Server (GPL)

	Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

To view the databases available to the root MySQL user, type the following at the mysql> prompt

	mysql> show databases;
	| Database           |
	| information_schema | 
	| mysql              | 
	| test               | 
	3 rows in set (0.00 sec)

	mysql> exit

Shutdown MySQL server:

	sudo /usr/local/mysql/bin/mysqladmin shutdown

Install Apache 2.0 with MacPorts

Because I wanted to maintain an Apache install independent of the default Mac OS X Apache WebServer, I chose to use MacPorts, which installs into /opt/local/apache2/. Find the latest version of Apache from MacPorts:

	port search apache

Find the latest port for Apache 2.8.8

	apache2	www/apache2	2.2.8	The extremely popular second version of the Apache http server

Get more information on the Apache 2 port

	port info apache2

List dependencies

	port deps apache2

Install Apache 2.2.8

	sudo port install apache2
	fetch failed

Apache 2.2.9 has been released, so the old version is no longer available

Install Apache 2.2.9

	sudo env MASTER_SITE_LOCAL= port -v fetch apache2
	sudo port install apache2

The install process provides feedback like this in Terminal:

		--->  Verifying checksum(s) for apache2
		--->  Extracting apache2
		--->  Configuring apache2
		--->  Building apache2 with target all
		--->  Staging apache2 into destroot
		--->  Creating launchd control script
		# A startup item has been generated that will aid in
		# starting apache2 with launchd. It is disabled
		# by default. Execute the following command to start it,
		# and to cause it to launch at startup:
		# sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
		Warning: apache2 requests to install files outside the common directory structure!
		--->  Installing apache2 2.2.9_1+darwin_9
		--->  Activating apache2 2.2.9_1+darwin_9
		--->  Cleaning apache2

Install Perl with MacPorts

Find the latest version of Perl from MacPorts:

	port search perl

Find the port for Perl 5.8.8

	perl5.8	lang/perl5.8	5.8.8	Perl 5.8.x - Practical Extraction and Report Language

Get more information on the Perl 5.8 port

	port info perl5.8

		perl5.8 5.8.8, Revision 2, lang/perl5.8 (Variants: darwin, threads, shared, darwin_8, darwin_9)

		Perl is a general-purpose programming language originally developed for text manipulation and now used for a wide range of tasks including system administration, web development, network programming, GUI development, and more.
		Platforms: darwin freebsd linux

Install Perl 5.8.8

	sudo port install perl5.8

		Skipping org.macports.activate (perl5.8 +darwin_8) since this port is already active
		--->  Cleaning perl5.8

I believe Perl had already been installed as one of the dependencies of Apache.

Install Mod Perl Apache Module with MacPorts

Find the latest version of Perl from MacPorts:

	port search perl

Find the port for mod_perl2

	mod_perl2	www/mod_perl2	2.0.3	Embeds a Perl interpreter in the Apache2 server

Install mod_perl

	sudo port install mod_perl2

Stop Mac OS X WebServer

Stop the native web server to avoid conflicts with MacPorts version

	sudo apachectl stop

A list of apachectl commands

	start      - start httpd
	stop       - stop httpd
	restart    - restart httpd if running by sending a SIGHUP or start if 
				 not running
	fullstatus - dump a full status screen; requires lynx and mod_status enabled
	status     - dump a short status screen; requires lynx and mod_status enabled
	graceful   - do a graceful restart by sending a SIGUSR1 or start if not running
	configtest - do a configuration syntax test
	help       - this screen

Modify the Apache Configuration file

Copy the sample configuration file

cd /opt/local/apache2/conf
sudo cp httpd.conf.sample httpd.conf

Enable mod_perl in the httpd.conf file by adding the following line to httpd.conf

	LoadModule perl_module modules/

Start MacPorts Apache2

Start Apache with the following command

	sudo /opt/local/apache2/bin/apachectl start

Test Apache Server

Go to http://localhost/. If all went well, there should be a message in the browser window with the following message:

It works!

Check out CVS project with AptanaStudio

Assuming AptanaStudio is already installed, documentation for CVS support can be found on the Aptana Plugins page:

CVS Support. This adds the Eclipse CVS plugins not bundled with Aptana Studio standalone.

  1. Go to the Update Manager in Aptana Studio via Help->Software Updates->Find and Install…
  2. Add a new Remote Update site to the following url:
  3. Install the Eclipse CVS feature from that update site

In Aptana, create a new project

	File > New > Project > CVS > Projects from CVS

Install Perl Packages

Several Perl modules are available from the CPAN. On the Mac, it seems to be far easier to use MacPorts for as many modules as are available. These are the modules that were required that could be found at MacPorts, listed according to the commands used to install the packages:

	sudo port install p5-archive-tar
	sudo port install p5-archive-zip
	sudo port install p5-authen-sasl
	sudo port install p5-bsd-resource
	sudo port install p5-bit-vector
	sudo port install p5-cache-cache
	sudo port install p5-class-singleton
	sudo port install p5-crypt-passwdmd5
	sudo port install p5-module-build
	sudo port install p5-datetime
	sudo port install p5-date-calc
	sudo port install p5-digest
	sudo port install p5-digest-hmac
	sudo port install p5-email-valid
	sudo port install p5-file-mmagic
	sudo port install p5-html-parser
	sudo port install p5-html-tree
	sudo port install p5-libwww-perl
	sudo port install p5-mailtools
	sudo port install p5-mime-lite
	sudo port install p5-module-install
	sudo port install p5-net-telnet
	sudo port install p5-soap-lite
	sudo port install p5-string-crc32
	sudo port install p5-text-csv
	sudo port install p5-timedate
	sudo port install p5-time-piece
	sudo port install p5-time-modules
	sudo port install p5-xml-simple
	sudo port install p5-cgi-simple
	sudo port install p5-mail-imapclient
	sudo port install p5-xml-rss
	sudo port install p5-perl-ldap
	sudo port install ImageMagick +perl	

I found a few more packages that might aid in developing an XSLT templating solution for our suite of tools

	sudo port install p5-xml-libxml
	sudo port install libxslt
	sudo port install p5-xml-libxslt

Those packages I could not find in MacPorts, I installed using CPAN, the Comprehensive Perl Archive Network. Mac OS X comes installed with Perl, along with a command line program, cpan, for installing Perl modules. Running the first cpan command begins an initialization process. I initialized it with all the default settings, by pressing the Return button when prompted to select an option, and ignoring any missing software.

	sudo cpan -i Crypt::Util
	sudo cpan -i Net::FTPServer::XferLog
	sudo cpan -i Chart::Graph::Gnuplot
	sudo cpan -i Math::FixedPrecision
	sudo cpan -i Net::LDAP
	sudo cpan -i SOAP::Amazon::S3
	sudo cpan -i MIME::WordDecoder
	sudo cpan -i DBI
	sudo cpan -i DBD::mysql

Configure Apache

To configure Apache to run Perl scripts in a specific directory, edit the configuration file.

	edit httpd.conf

Then add directives for each directory:

	### Perl directories: execute scripts in these directories
	<Directory "/opt/local/apache2/htdocs/perl/*">
		Options Indexes FollowSymLinks +ExecCGI
		AllowOverride All
		Order allow,deny
		Allow from all
	<Directory "/opt/local/apache2/htdocs/symperl/*">
		Options Indexes FollowSymLinks +ExecCGI
		AllowOverride All
		Order allow,deny
		Allow from all

Running Multiple Apache Web Servers

To be able to run the default Mac OS X Web Server, the MacPorts Apache 2 Web Server, and MAMP simultaneously, I can run each server on a different port. For the MacPorts server, I modified the Apache configuration file to run the server on port 3000.

	cd /opt/local/apache2/conf
	edit httpd.conf

Look for a line that directs the server to run on the default port, port 80:

	Listen 80

Then, to run the server on port 3000, change the line to this:

	Listen 3000

To have completely separate installs of Apache, including separate MySQL installs, I should also install MySQL using MacPorts. That way, I can have multiple instances of MySQL running on different ports. However, that seems a little overkill (if this whole setup doesn’t already). So, that’s my development environment.


About this entry