Learn how to setup a web server pt1: Setting up a practice server

VirtualBox

So you want to be a bit productive this holiday/winter/end-of-year break and decide to learn how to setup your own website.

But for some odd reason you don’t want to settle with a free website service like WordPress or even a cPanel managed shared hosting site. Instead, you want to know how to setup your own web server, something like a Linode VPS or an Amazon EC2 instance.

Luckily for you, I’m having a bit of a writer’s block and I have time to write about how to learn setting up a Linux server without having to pull out your credit card.

What this post is all about

In this post, we’ll just discuss how to set up a virtual server on your computer.

Yes, that’s right. We’re not installing a server OS on a spare machine, nor are we dual-booting: we’ll be setting up a server in your desktop, running the former inside the latter. This is virtualization, dawg.

We’ll be creating a server with somewhat similar specs to what you’d get if you sign up for $8 a month at prgmr.com. This simulated environment will be enough for a newbie to learn the ropes in server management.

What you need

Any relatively modern desktop or laptop computer will do. For this series of posts, I’ll be forgoing the use of my quad-core gaming rig and instead use my laptop (dual-core @ 2.1GHz with 3GB RAM). For the sake of the majority of the readers, I’ll be using Windows 7 as the OS though the steps will almost be the same when using Windows XP and Vista, and will still be similar even when using Linux or OSX.

You also need to be connected to a network, preferably one that gives out local IP addresses via a DHCP server. In other words, a home/office router. Fast internet also helps as you need to download >700MB worth of installer data.

As for the software, you will need to download VirtualBox and a CD image (.iso) for Ubuntu Server 10.04.3 Long Term Support 32-bit. The VirtualBox download and installation is pretty straightforward, but for the Ubuntu Server 10.04.3, you may want to choose downloading via BitTorrent for faster download speed.

Unlike Linux and OSX users who already have it built in on their terminals, Windows users will also have to download an SSH client like PuTTy, the one that you’ll see in this tutorial.

Continue reading “Learn how to setup a web server pt1: Setting up a practice server”

Rails Development Server is Slow

Problem:

When developing for Ruby on Rails, the development server (the one used by script/server) feels slow and unresponsive.

Cause:

RoR uses WEBrick as the default server. Based on my experience on a Ubuntu virtual machine with 1GB of RAM, this server doesn’t respond as fast as the web application servers in other web languages (Apache, Tomcat, IIS).

Solution:

Install Mongrel. In Ubuntu 9.04, you can install this using:

sudo gem install mongrel

In case you receive build errors, you might have to install ruby-dev to deal with the dependency issues.

sudo apt-get install ruby-dev

Once installed, Rails will automatically use Mongrel as the application server over WEBrick.

UPDATE: Mongrel’s pretty much dead by now. Use thin instead.

Just add gem 'thin' to your Gemfile and run bundle install.