The Great Server Upgrade

Meticulous has numerous servers online. This site happens to reside on our rails development server named “Cuba”. It’s on the development server because I can try things out without taking down our main production boxen (Athena & Hercules). Athena’s been around for a while and was stuck on Apache 1.3.×. We had some rails apps we had recently deployed that were just not cutting it with mod_fastcgi on the server, and we decided to upgrade the server in one fell swoop to give us the new hotness.

Our install list included:

  • Apache 2.2.4
  • PHP5
  • PHP5 Extentions
  • mod_fastcgi
  • smarty
  • Subversion
  • Ruby 1.8.5
  • Ruby Gems, Rails, Mongrel, Mongrel_cluster, Capistrano, etc etc.

The install process was simple enough but the depencies bug hit us hard.


root@athena# cd www/apache22
root@athena# make install clean
===> Installing for apache-2.2.4

===> apache-2.2.4 conflicts with installed package(s):

They install files into the same place. Please remove them first with pkg_delete(1).
  • Error code 1

Stop in /usr/ports/www/apache22.
root@athena# pkg_delete
pkg_delete: missing package name(s)
usage: pkg_delete [-dDfGinrvxX] [-p prefix] pkg-name …
pkg_delete -a [flags]
root@athena# apachectl stop
/usr/local/sbin/apachectl stop: httpd stopped
root@athena# pkg_delete apache-1.3.33_1
pkg_delete: package ‘apache-1.3.33_1’ is required by these other packages
and may not be deinstalled:

Basically, we had to delete those packages in reverse-dependency order and then do Apache, PHP5, the PHP5 extensions, etc. following.

Virtual Host Love

One of the biggest benefits of Apache 2 is the Includes directory in /usr/local/etc/apache2. This directory has individual files setup for each Virtual host on the system. We have something over 160 virtual hosts on our main production box, and they were all listed in the Apache 1.3 httpd.conf file.

Justin flexed his ruby muscles and came up with a script that took the Virtual Hosts area of the httpd.conf file and parsed them into individual files.


  1. Parsing code at the bottom.
    data = ’

{Your VirtualHost config here}

WRITE_DIR = “/full/path/to/where/you/want/these/saved”

ary = data.split(“”)

    ary.each do |x|
    site_name = x.match(/(ServerName)(\s)(\w.)/)
    site_name = site_name.to_s.gsub(/(ServerName)(\s)(\w.
    )$/, ‘\3’) + “.conf”
    site_name = site_name.gsub(" ", "").gsub(“\t”,"") # Strip out whitespaces
    puts site_name

ary.each do |x|

  1. Strip out the multiple line breaks
    site_conf = x.gsub(“\n\n”, "")
  1. Add back in the closer (which gets omitted with strip)
    site_conf += “\”
  1. Find the ServerName … line
    site_name = x.match(/(ServerName)(\s)(\w.*)/)
  1. Remove apache ServerName … code, leaving domain name. Append .conf to the name for writing.
    site_name = site_name.to_s.gsub(/(ServerName)(\s)(\w.*)$/, ‘\3’) + “.conf”
  1. Strip out any whitespaces in the name
    filename = site_name.gsub(" ", "").gsub(“\t”,"")
  1. puts filename # testing
  2. puts site_conf # testing
if File.exists?(WRITE_DIR + filename) puts "\nEXISTS: " + site_name end the_file = + filename, “w”) the_file << site_conf the_file.close


This created 164 files with domainname.ext.conf as the file name. There were a few places where extra white space caused lines to jump onto other lines, but in general it was quite efficient and saved us hours of manual labor copying and pasting the config.

So now it’s time to get mongrel proxies running for all the rails sites. And deal with the boards issues that are sure to come up. And get mod_deflate running. The fun never ends!

UPDATE Looks like it’s all happy. A few “best practices” cleanup things we need to do on various sites, but all in all, not bad. Now, to migrate the DNS and email servers.

  1. Tabish says:

    What's the error message that your genttig? Entering shell is pretty fundamental to the OS, so unless you've made some changes that you can back out and at least get the system back to a level footing, the options may be limited.

Post a comment

Name or OpenID (required)

(lesstile enabled - surround code blocks with ---)