HowTo:

Set up a cheap Ubuntu server for web development, file serving and as a platform for hosting Freeciv network multiplayer games over your home internet connection.

First Step: Find a computer to use as your server. Well, I suppose most of you will have an old PC in your closet collecting dust, and that'll probably serve fine, as long as it has a decent processor and a reasonable amount of RAM.

My first attempt at this, I used an old Dell Inspiron 8100 laptop, which was a bit too slow at 1ghz and 512mb RAM when processing Freeciv turns. It also had a bad ethernet card and the USB ports were not 2.0 compliant, making the idea of serving files and games with such a wimpy speed over a wifi connection pretty iffy. So eventually I turned to a Frankenstein tower that was made up of various spare parts. Frankie had a bit more ooph - at 1.6ghz and 1gb RAM, Turns processed much snappier and I could finally attach my USB drives and serve files over a USB 2.0 connection.

Frankie had a problem, though. He'd run fine for a few days and then suddenly develop a bad habit of spontaneously rebooting over and over for no apparent reason. Sometimes on boot, he'd not even pass POST and he'd just sit there and beep at me while constantly power cycling. Needless to say, this put a crimp in my definition of "server", because one expects a server to be a little more reliable than that. I was faced with either going back to the slow-ass Dell, somehow figuring out why Frankie was so tempramental and fixing that, or buying another computer entirely. Sheesh. The whole point of this exercise was to get it done *cheaply*, so my options were looking pretty thin.

Ebay to the rescue! I started poking around the normal cheap computer sites like NewEgg and Tiger Direct searching under the "Desktop PC's under $200" categories, and found the pickings fairly thin, but there were a lot of "out of stock" pages for lease-return refurbished IBM small form-factor ThinkCentres with processor speeds between 2.6ghz and 3.2ghz. A quick check on Ebay indicated that there were palletfulls of these guys being sold for around $120 each with 512mb of RAM and 40gb drives in them. They take DDR1 RAM, so the 1gb stick I had in Frankie should work with them. Further checking revealed a seller unloading them for $59 (shipping included!), sans drives, and I was sold. With 8 USB 2.0 ports in it, small form factor and power consumption and a processor twice as fast as Frankie, it matched all of my requirements.

Second Step: Ubuntu Server or Desktop version? Having attempted this install a few times on my broken-ass hardware, I had some experience with both versions because I'd tried both and not noticed much of a speed difference between the two. For my final install on the ThinkCentre, I chose the Desktop version, just because it's easier to maintain and work with. If you're not super comfortable with the command line only, then you should pick the Desktop version also. This HowTo assumes that you're using the Desktop version.

Now we get down to the nitty-gritty of installing the software you need and setting it up to do what you want:

  1. Install Ubuntu Desktop on your spare computer (I used 9.04 RC Jaunty Jackalope).
  2. Install Apache2/PHP5/MySQL5 using Synaptic Package Manager
  3. Install PHPMyAdmin
  4. Set up Apache to serve user's public_html directories [ source ]
  5. Set up Ubuntu for static local IP address. [ source ]
  6. Set up an account at no-ip.com and install the no-ip client. [ source ]
  7. Many ISPs and Cable Internet Providers block port 80 and port 8080 to inbound connections. Luckily, No-IP.com allows you to do a port 80 redirect. You'll need to change the Apache config to handle the connections to the non-standard port for web traffic. Alter the apache config to cause Apache to listen to the alternate port.
  8. Set up your router to direct traffic to your server.
  9. Create a user called "freeciv", and set up a public_html directory and MySQL database for that user.
  10. Install FreeCiv with MySQL Authentication [ source ]
  11. Install GifSicle for the creation of animated gifs.
(More coming soon...)
Thanks go to Book and Cazfi, for changes to the Freeciv logging and filenaming code, which helped make this project possible.

Additional Tweaks and Tips:

LongTurn Rulesets: The LongTurn variant of online Freeciv generally uses a timeout period of 24 hours, plus some additional ruleset changes that help speed up gameplay. You'll need to set up a LongTurn ruleset directory and a server rules file. If you'd like some examples to start with, you can try ours, which can be downloaded by selecting one of the more recent games listed to the right.

Suppose you accidentally set a blank string for the savegame filename prefix in your server starting script? You wouldn't be the only one, because I did it too. It's harder to fix than you think using "rename" or other bulk file remaing tools, mainly because of the "-" at the beginning of the resulting filenames. It sets a flag in "mv" and "cp" and it needs to be escaped. Here's a nice shell scriptlet that I found does the trick:

for file in \-*gz; do mv -- "$file" "newprefix`echo $file`"; done