Sat 12 July 2008
Rotoscope Cannonball Productions Meticulous Boboroshi & Kynz

masthead image

boboroshi.com - fitter. happier. more 70s wallpaper.

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.x. 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): 
      apache-1.3.33_1

      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:
mod_gzip-1.3.26.1a
smarty-2.6.7
php4-bz2-4.3.10_2
php4-ctype-4.3.10_2
php4-gd-4.3.10_2
php4-gettext-4.3.10_2
pecl-imagick-0.9.11_1
php4-mysql-4.3.10_2
php4-overload-4.3.10_2
php4-pcre-4.3.10_2
php4-posix-4.3.10_2
php4-session-4.3.10_2
php4-tokenizer-4.3.10_2
php4-xml-4.3.10_2
php4-zlib-4.3.10_2
php4-extensions-1.0
mod_php4-4.3.10_2,1
mod_ruby-1.2.4

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.


# Parsing code at the bottom.
data = '

{Your VirtualHost config here}

'

WRITE_DIR = "/full/path/to/where/you/want/these/saved" 

ary = data.split("</VirtualHost>")

# TESTING
#=begin
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
end
#=end

ary.each do |x|
  # Strip out the multiple line breaks
  site_conf = x.gsub("\n\n", "")  

  # Add back in the </virtualhost> closer (which gets omitted with strip)
  site_conf += "\</VirtualHost>" 

  # Find the ServerName ... line
  site_name = x.match(/(ServerName)(\s)(\w.*)/)

  # 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" 

  # Strip out any whitespaces in the name
  filename = site_name.gsub(" ", "").gsub("\t","")

#  puts filename    # testing
#  puts site_conf   # testing

  if File.exists?(WRITE_DIR + filename)
    puts "\nEXISTS: " + site_name
  end

  the_file = File.new(WRITE_DIR + filename, "w")
    the_file << site_conf
  the_file.close

end

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 nancies.org 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.

Leave a Reply