mariusv.com

Watch as I awkwardly stumble through life

RackSpace Cloud new server script

Posted by Marius Voila on July 21, 2010 in London, U.K . — 0 comments This post contains 392 words

I’ve found myself setting up lots of servers over at RackSpace Cloud lately. It seemed look a good idea to automate everything instead of leaving it up to myself to remember everything you have to do each time.

I wrote this little shell script to make life easier. It installs everything I need to run a Ruby on Rails app in a matter of minutes. It’s designed to work with Cent OS 5.4+. Here’s the script’s main tasks:

For me, that’s enough to get the bare bones of an app running. The rest, I let Bundler handle for me. I use this on all of my servers that I manage.

Let’s get started already

All you have to do to setup your new server is run the following one line:

<code>$ wget http://gist.github.com/raw/478226/server.sh
$ chmod +x server.sh
$ ./server.sh
</code>

You’ll have to press y twice at the beginning when yum asks you to install some stuff. After that, you can let it do its thing.

Configuration

It’s super easy to add a new Nginx virtual host. All you have to do is add a file with the .conf extension to /usr/local/nginx/conf/virtual_hosts/. Here’s a good example virtual host. Of course, you can configure any of the installed stuff like you normally would. My nginx.conf just makes setting up virtual hosts easy. After you edit any of the Nginx configuration files, you’ll want to run service nginx reload to apply your changes.

One more thing

There’s also another little script that I run after the main one that is more specific to my needs. This little guy creates /var/www/, setups the proper permissions, and installs some database related gems. You can run it with the following one line:

<code>$ wget http://gist.github.com/raw/478242/after.sh
$ chmod +x after.sh
$ ./after.sh
</code>