fluidBlog

April 1, 2007

Installing Typo on Fedora 6 slice from Slicehost

Filed under: Deployment, Fedora, Installation, Rails — trekr @ 11:05 am

Like it says on the typo wiki download page, it could be as easy as

$ gem install typo

$ typo install /some/directory

For the above to work, we need to satisfy some dependencies. This post will step through what is needed to get a typo instance up and running on a new Fedora 6 Slice from Slicehost .

You need to have the rails stack in place, see my earlier post Installing Rails on Fedora 6, and download the script install_rails_fc6-sh

Assuming a brand new Fedora 6 slice from Slicehost with DNS set up, login in to your slice and change the root password.

[root@localhost ~]$ slogin example.com

On your local server, as root, copy the script to your slice

[root@localhost ~]$ ssh example.com cat < install_rails_fc6-sh ">" install_rails_fc6-sh

Log back into your slice, and execute the script

[root@localhost ~]$ slogin example.com

[root@example.com ~]$ /bin/bash install_rails_fc6-sh

Next we need sqlite3. The gem thinks sqlite3-ruby is a required dependency even if you don’t plan on using sqlite3.

Before you install sqlite3, you’ll need c++

[root@exammple.com ~]$ yum install gcc-c++

I couldn’t figure out how to yum install sqlite3, so we’ll roll our own. Change to your favorite source directory to build source

[root@example.com ~]$ cd /usr/local/src

[root@example.com src]$ /usr/bin/wget http://www.sqlite.org/sqlite-3.3.13.tar.gz

[root@example.com src]/bin/tar xvf sqlite-3.3.13.tar.gz

[root@example.com src]$ cd sqlite-3.3.13

[root@example.com sqlite-3.3.13]$ ./configure

[root@example.com sqlite-3.3.13]$ /usr/bin/make

[root@example.com sqlite-3.3.13]$ /usr/bin/make install

Now you should be able to run

[root@example.com ~]$ /usr/bin/gem install typo

[root@example.com ~]$ typo install /var/www/apps/mytypo-directory

Obviously, change mytypo-directory to whatever you’d like to call your typo install directory.

I like the apache+mongrel setup, so I followed the configuration that the excellent deprec gem uses.

Download typo.conf and move it to your slice in the directory /etc/httpd/conf/apps/.

Edit the file, replacing example.com with your hostname, change the <directory> directive, and set the balance member ports to the ones you’ll configure the cluster with.

Check your config with

[root@example.com ~]$ /usr/sbin/apachectl configtest

Configure the mongrels as shown here

Change directories to the directory where you installed typo

[root@example.com ~]$ cd /var/www/apps/mytypo-directory

[root@example.com directory]$ /usr/bin/mongrel_rails cluster::configure -e production -p 8000 -N 2 -c /var/www/apps/mytypo-directory -a 127.0.0.1

If you didn’t run install_rails_fc6-sh, you’ll need to configure mongrel to run after reboot

[root@example.com ~]$ /sbin/chkconfig --add mongrel_cluster

[root@example.com ~]$ /sbin/chkconfig --level 345 mongrel_cluster on

If the chkconfig commands fail with a don't know, make sure that you have the init script in /etc/init.d/. Copy it from the gem

[root@example.com ~]$ /bin/cp /usr/lib64/ruby/gems/1.8/gems/mongrel_cluster-0.2.1/resources/mongrel_cluster /etc/init.d/

Restart apache

[root@example.com ~]$ /usr/sbin/apachectl graceful

and login to your typo instance via your browser at the URL

http://www.example.com/admin

In this post, we installed typo directly on the slice as root to simplify the steps. You want to setup a user and install typo as that user. Also, in this post we used the default sqlite3 database.

Finally, there are a few things left to consider like backing up the database and putting your instance of typo under version control. I’ll cover these topics in a future post.

Update: 5 April

I revised the steps to make them a little clearer, and tested on my sandbox slice.

Installing Rails on Fedora 6

Filed under: Deployment, Fedora, Installation, Linux, Rails — trekr @ 9:16 am

I had read some good things here and here about the deprec gem, so I thought I’d look into using it set up a new slice at Slicehost. deprec was written with Ubuntu as the target distribution. Mike Bailey, the creator of deprec, is very clear about that, so I expected some problems making it work for Fedora. I followed the instructions on the slicehost wiki.

variorum

Lets go straight to the end of the story in the same spirit of the slicehost wiki. The command 'cap installrailsstack’ will not work on Fedora because it relies on 'apt-get'. So we’ll be writing our own shell script to 'yum install' what we need. Another change we’ll need to make is in the file deprec-1.3.1/lib/deprec/thirdparty/mongrelcluster/recipes.rb. Here we need to replace 'update-rc.d' with 'chkconfig'. See the comments in the script to perform this step manually, the script doesn’t touch the deprec gem. Finally, because deprec installs apache from source into '/usr/local/apache2' and we are going to 'yum install httpd', we’ll need to set up some directories that 'cap deprec_setup' is expecting. Additionally, we’ll be setting up mysql to start at boot, and setting the ServerName to hostname in /etc/httpd/conf/httpd.conf. You still need to setup the initial database accounts and turn off root login via ssh. See the comments for the commands.

The wiki can be successfully followed after running the installrailsfc6.sh (download) by just skipping the command 'cap installrailsstack’. The comments at the top of the script walk you through the steps, so I’m not going to walk through it here. If the comments in the script are too arcane, please let me know.

You’ll note that the script must be executed as root because sudo is not available on a new FC6 slice. You may prefer to install sudo and execute the remaining commands using sudo. Please don’t download and execute the script without thoroughly confirming that it will do what you want. The script is intended to be run on a newly built slice, so don’t run it if you have already started configuring your system, I haven’t tested that scenario. I don’t recommend executing the script remotely via ssh because some of the gem install’s are interactive, and at least for me didn’t wait for input when executed remotely. I’m not the only one to comment on this feature . Move the script to your slice using ssh, see the comments in the script for the command.

Warning: Opinion Follows

My personal opinion is that setting up the Rails stack is best handled by using the shell and package manager for your distribution. This script has not improved upon the weaknesses present in deprec. Namely, hard coded versions, URLs, paths, etc. Therefore, I don’t recommend that you execute this script without reviewing it carefully precisely because it is likely to fail in the future when versions and URLs change. This is the beauty of using a package manager, all those details are handled for you. Unfortunately, not everything we need for a Rails stack can be yum installed. This script is quick and dirty and passes only the “Works on my Machine” test, where “my machine” is a Slicehost FC6 slice circa March 2007. Although I have tested the script many times, it is, nevertheless, a first pass at documenting the process (executable documentation tends to be more repeatable). OK, you’ve been warned.

Update 4 April

I retested the script today and sure enough, it was broken. For some reason, it no longer copies the init script mongrel_cluster to /etc/init.d. You’ll see these errors when the script tries to setup mongrel to start after a reboot.

error reading information on service mongrel_cluster: No such file or directory

error reading information on service mongrel_cluster: No such file or directory We need to copy

/usr/lib64/ruby/gems/1.8/gems/mongrelcluster-0.2.1/resources/mongrelcluster

to /etc/init.d/ and change permission to make it executable.

chmod 755

I’ve updated the script. IMHO, the gem package for Mongrel needs to work with the version option. The quick fix just adds to the problem by hardcoding another version …

Hakota Design LLC