Posts tagged Slicehost

Aug 29, 2007

Adding a mongrel instance to a Slicehost Rails app

Ruby on Rails mongrel Slicehost Ruby on Rails mongrel Slicehost | comments

Photo by caribbean

Let’s say you have a Ruby on Rails website hosted at Slicehost. Let’s also say you used the snazzy deprec instructions to install said web site. And finally, let’s say said website is receiving increased traffic. Well, you may very well need to add another mongrel instance so your site’s performance remains acceptable.

That’s easy!

  • Add 1 to the “servers” parameter in /etc/mongrel_cluster/appname.yml.
Maruku could not parse this XML/HTML: 
<pre>servers: 3  # previously was 2
  • Add another balance member to /usr/local/apache2/conf/apps/appname.conf:
Maruku could not parse this XML/HTML: 
BalancerMember  # Added this one
  • Restart the mongrel cluster using Capistrano:
cap restart_mongrel_cluster
  • Restart the apache server using Capistrano:
cap restart_apache   # or cap apache_restart

You’re done!

Jul 18, 2007

Redirecting a subdomain to a URL at Slicehost

Slicehost Slicehost | comments

With Dreamhost as my web host, I had gotten in the habit of using subdomain redirects to create convenient URL’s, both for users and myself. So to get to the Scrawlers blog one could enter “” in one’s web browser. For my own convenience, I’d typically have a subdomain to redirect to the blog’s administration panels. And so on.

Now that I’m with a real VPS, Slicehost (referral link), I need to get more hands-on in managing these subdomain redirects. In a word, I need to start using Apache virtual hosts.

But first, I needed to setup a DNS record for the subdomain. This assumes you have your other DNS stuff for your domain working. Navigate through your Slice’s DNS record menus to create a new record for the target domain.

  • Under the Slices tab, click “DNS Records”
  • For the target domain, click “records”
  • Click “new record”

In this example, I’m going to forward to the main Google search page. So enter “goog” as the Name and your Slice’s IP address as the IP Address. Clearly my IP Address is made up.

Dns Setup

Now to update Apache to handle redirecting. I used the excellent deprec tutorial to install my Rails stack, so Apache resides in /usr/local/apache2 on my slice. For redirection, I chose to make a new directory in the configuration area, and create a virtual hosts file per domain. My virtual host file, in this case, is located at /usr/local/apache2/conf/redirects/ This definition is pretty simplistic

<VirtualHost *:80>
  Redirect permanent /

In reality I have about 8 VirtualHost definitions in my file. If you had defined multiple subdomains to redirect to the same place, say to account for typos or pluralization, there is no need to define multiple VirtualHosts. Simply use the ServerAlias keyword. For example:

<VirtualHost *:80>
  Redirect permanent /

Finally, you need to edit your base Apache config to include all configurations defined in the “redirects” directory. In my case, this base config file is at /usr/local/apache2/conf/httpd.conf. At the end of this file, add the line:

Include conf/redirects/

Now restart Apache, either through capistrano (cap apache_restart) or directly on the server. Depending on how quickly you work, you may need to give DNS some time to sort itself out. It shouldn’t take more than an hour, though.