(not going to finish) Production web serving with Cygwin - PHP, Ruby on Rails & ColdFusion


Note: I'm not going to finish this article as ultimately I ran into problems with Cygwin so migrated to running all Windows-native tasks. Still, in its raw state someone might find some use out of it.

Web development is an interesting field. Many of the technologies you try or wish to use work best with a specific requirement, for example despite attempts to the contrary ASP simply works best on Windows with IIS. Another example of this notion that has become rather common of late is that Ruby on Rails and its related tools really work best on UNIX-like operating systems and doesn't work as well on Windows.

For those "stuck" with Windows for their production web serving there is, however, a work-around called Cygwin, a UNIX compatiblity layer for Windows that has been around since the mid 90's so is very mature and well supported. Cygwin provides the best of both the UNIX world with a robust platform for running many UNIX-only tools, while still providing the Windows foundation which is often needed for e.g. proprietary database drivers. Read on as a give a full list of what you need to install, and how to configure, all of the tools necessary for a pretty comprehensive web development production environment.

Installing Cygwin

The first step is to obtain the Cygwin installer executable from Run the cygwin.exe program when you download it and you'll see something like the following:
Following through the prompts you'll want to first "Install from Internet" to download all of the required files and install them immediately. On the next screen you'll pick where to install Cygwin, whether to install it for all users or just yourself and whether to make data files use the UNIX or DOS/Windows format - I only ever change the directory path and leave the others at the defaults; the next screen asks where you want to keep the downloaded files, I recommend a sub-directory of where you're installing the main Cygwin system, just to keep them close at hand. The next two screens will ask for your network settings (most people can leave the defaults) and then to pick the Cygwin server to obtain all of the files from - I suggest going through the list and trying some to see how fast they are before picking a favorite.

The next screen is where all the fun is - you get to pick what software to install. I recommend clicking the "View" button to make the list change to a plain list of all of the available software, and maximizing the window, as it can be confusing to work out what category certain apps are in.
Here are the packages we are going to need, besides the basics:

  • apache2
  • gcc
  • gcc-g++
  • gnupg
  • ImageMagick
  • nano
  • curl
  • mhash
  • openssh
  • ruby
  • subversion
  • unzip
  • wget
  • whois
  • make
  • openssl-devel
  • ping
  • bison
  • flex
  • libmcrypt
  • libmcrypt-devel

ssh-host-config -y
Give a password
ntsec tty

make -f Makefile.cygwin
make -f Makefile.cygwin install

Ruby on Rails

ruby installed via cygwin
download rubygems
ruby setup.rb
gem install --remote --include-dependencies rails
gem install --remote --include-dependencies mongrel
gem install --remote --include-dependencies mongrel_cluster
gem install --remote --include-dependencies capistrano
gem install --remote --include-dependencies image_science
gem install --remote --include-dependencies hpricot

SQL Server

dmckenna@websrv /home/dmckenna/ruby-dbi
$ mkdir /lib/ruby/site_ruby/1.8/DBD

dmckenna@websrv /home/dmckenna/ruby-dbi
$ mkdir /lib/ruby/site_ruby/1.8/DBD/ADO

dmckenna@websrv /home/dmckenna/ruby-dbi
$ cp lib/dbd/ADO.rb /lib/ruby/site_ruby/1.8/DBD/ADO

ColdFusion is *not* Java


Scott Stroz just posted a great article over on Doug Hughe's site regarding the tendency some people have of rejecting feature additions to ColdFusion because the feature can be done using CFML's Java underbelly. In my 3.5 years of developing with ColdFusion full-time I've seen countless times that experienced developers recommend that others "just use Java" to fill in missing functionality in ColdFusion, functionality typically available in competing technologies like Ruby, PHP or C#.

I started using CFMX6 and was immediately impressed by how easy basic things were. Want a query? Just use one simple command. Want to display your results? Just loop over the results or just start using the query variables on your page - it automatically shows the first record if you don't tell it otherwise. Easy, just like it should be. In addition there was extra depth behind it - CFML's object oriented system, frameworks, etc, allowed those who needed more to do so, while still staying in CFML.

As someone who came from a PHP background it was, however, rather apparent that even back then there were a few things missing - image handling, secure transfers and a database agnostic querying system were obvious ones to me. CFMX7 did not appear to me to further the cause - most of the additions seemed to be aimed at the "enterprisey" market, especially the event gateway feature, and most users weren't going to spend $6000 on that.

The folks that recommended using Java for day-to-day things were IMHO short-sighted and were doing ColdFusion a disservice - what should have been a push from the community to get the feature added to the core system, to have another feature given the "ColdFusion easy-to-use" work-over, the developer was being pushed towards a much, much more difficult technology. People who learn ColdFusion don't do so to use Java, they do it to use ColdFusion, just like you wouldn't learn PHP to use the C++ language it is written in.

Thankfully ColdFusion 8 (the "MX" was disposed of) has brought it back to where it should have been - neck and neck with similar tools, ahead in some cases, and back to making simple websites simple again. No more will we have to "just learn Java" to resize an image, or securely transfer files from other servers, and we gain easier AJAX routines, easier page layouts, and many more tangible and more usable features that will benefit a greater portion of the market, all wrapped up in an easy-to-use package.

So, well done Adobe, ColdFusion 8 is great, and I've got a request in at work to upgrade to the newest version.

World's worst industry publication ceases


Sys-Con have finally put to rest what I’ve thought was an utterly horrible magazine, the ColdFusion Developer’s Journal. Between an utterly useless website that bombards you with 80% advertisements / 20% content, and a magazine with legally questionable practices (using blog articles without consent or payment), the ColdFusion industry is much better off without them.

Yes, the above is what one of the company’s sub-sites looks like. Yes, that is a pop-over advertisement for one of their magazines. Yes, that is an auto-play video advertisement. Yes, this is a really, really bad website, worthy of the next edition of Web Pages That Suck.

Amusingly, during the past year, when most of the really bad stuff came to light, a new magazine called the Fusion Authority Quarterly Update stepped up to the plate and utterly trounces anything SysCon has done in years. Good riddens to CFDJ, we’ve got FAQU now.

Access queries as structs in ColdFusion


A small tip, but a very, very useful one nonetheless. Did you know that in ColdFusion you don't have to loop through a query to access specific elements of the query? I've been developing in CFML for several years and was unaware of this. It's great! Instead of having to go through the hassle of looping an array just to find one field, if you know the field and row number you can just do this:

<cfset variable = query[column_name][row_number] />


<cfset variables.product_name = variables.q_products[name][5] />

Thanks to Ben Nadel for that.

Sometimes you just feel like a complete neophyte. I wonder what other useful tricks lie beneath the surface?

Fusebox 5.5-alpha documentation released


If, as a web developer, you aren't structuring your code in a clean fashion then you owe it to yourself to use a pre-existing code framework rather than reinventing the wheel.

In the ColdFusion world one of the oldest and still most popular is Fusebox, a framework that has gone through many major changes over the years and unfortunately has gotten a bit more complicated with each release. That complexity is going by the wayside with the upcoming v5.5 release as a number of improvements will greatly simplify developing applications using it.

Key benefits to all users are the use of convention over configuration to leave you with almost configuration-free applications, and the ability to use ColdFusion Components (CFCs) as circuits. These two features alone would make it a very worthwhile release, but the lead develeper, Sean Corfield, has many more lined up.


Subscribe to ColdFusion