Ubuntu 8.04 Rails Server Using Passenger 17

Posted by Ron Valente Wed, 07 May 2008 02:50:00 GMT

Introduction

So before my monstrous OpenSolaris 2008.05 post on setting up a Ruby on Rails server I decided to write a guide on setting up a Ubuntu 8.04 server guide for all you Slicehost users! I decided to write this guide because of the new optimized kernel that was added to Ubuntu Server 8.04 for virtualized environments. I also wanted a complete guide that would be a solid reference and now just have bits and pieces for upcoming sysadmins will get lost when reading.

For simplicity I will start with a black machine and build upon that. Use the comments section for specific questions or starting points. I will try to do my best at answering any and all questions.

Requirements

This section will go over the simple requirements of the entire setup.

Hardware

Ubuntu 8.04 Server - This could be anything below:

  • Slicehost
  • VMware
  • Bare Metal Install

Software

  • Apache 2.2.8
  • MySQL/PostgreSQL/SQLite3
  • Git
  • Ruby
  • Rubygems
    • Rails
    • Capistrano
    • RSpec
    • Ultrasphinx
    • Passenger

Installation of Software

First thing before we start installing anything on this machine we must update the server. This is very simple with Ubuntu, it is two simple commands and you are all set. You only need to reboot the machine if a kernel was installed.

sudo apt-get update
sudo apt-get dist-upgrade

Now that the machine is updated we must install some essential tools in order to build software on this server. Once we are done with the setup it would be a good idea to remove these tools to increase security on our server.

sudo apt-get install build-essential

Now we are all set with the preparation of the server and we can start installing the software we need to get going.

Web Server

For the web server I chose to use Apache 2 because of the new Passenger gem or (mod_rails). This gem is great because of the simplicity to deploy new applications.

sudo apt-get install apache2 apache2-dev

Database Server

The database server that should be used is completely up to your preference. My recommendation is PostgreSQL. PostgreSQL is a very robust and fast database server that is rock solid. It does use a lot of resources so for Slicehost it may not be the best choice. A major player for a slim and fast database for Slicehost should be SQLite3. It is a wonderful database and should be thrown out so quickly because of its lack of a client/server architecture.

For this tutorial I will install MySQL because of its popularity with the Rails community.

sudo apt-get install mysql-server

When prompted enter a root password, make this complex and write it down.

Version Control

Git is the most sexy version control system every created. I will never look back to subversion again. Now that capistraon and redmine both support git I have no reason to even thing about those awful three letters.

To install git is yet another apt-get command away. Run the following command in the terminal of your new server.

sudo apt-get install git-core curl gitweb

gitweb is an optional web frontend for your applications. I do not use it because I use GitNub a RubyCocoa application for the Mac.

Once that finishes git is completely installed and ready to go.

Ruby

Installing Ruby on Ubuntu 8.04 is quite simple. Just another apt-get and you are all set... almost. Since the inception of Ruby 1.9.0 distributions have been naming the current stable release of ruby "ruby1.8" That being said we will make a couple symlinks.

Ruby 1.8.6

To install all the tools you will want on this server run the following command:

sudo apt-get install ruby1.8 ruby1.8-dev rdoc1.8 ri1.8 libopenssl-ruby1.8

Rubygems

I refuse to install Rubygems with apt-get. This is such a terrible idea in my opinion. There is no reason to install rubygems with a package manager because it can update itself. I will go over how to update rubygems later in this howto.

wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
tar -xzf rubygems-1.1.1.tgz
cd rubygems-1.1.1
sudo ruby1.8 setup.rb

Optional: Once you are done with install just run the next three commands to make using gems and Rubygems just as before.

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby
sudo ln -s /usr/bin/irb1.8 /usr/bin/irb

Recommended Gems

Here is a list of recommended gems that should be installed once rubygems is installed. At the very least you must install rails and passenger.

sudo gem install rails
sudo gem install capistrano
sudo gem install rspec
sudo gem install ultrasphinx
sudo gem install passenger
sudo gem install mysql

Part Two

Next week I will go over how to connect all the pieces together and get a sexy Ruby on Rails server running smoothly. I will go over configuring git on your local computer as well as setting up passenger and capistrano to function with all of the above sexy applications we just installed.

Updating Ruby on Rails on Mac OS X Leopard 1

Posted by Ron Valente Tue, 08 Jan 2008 06:56:00 GMT

Introduction

The purpose of this post is to quickly and efficiently update you Ruby on Rails stack on Mac OS X Leopard.

Requirements

Caution: Before this procedure is start you must have a cursory knowledge of using the Terminal in Mac OS X.

  • Fully Patched Install of Mac OS X Leopard
  • Apple Developer Tools

Procedure

  1. Open Terminal

  2. Run the following

    sudo gem update –system

  3. Run the following command to update all your installed gems to the latest version

    sudo gem update

  4. That is it!

Note: All the previously installed gems will stay installed as a backup but ruby will use the latest gems that are installed on the system.

Tip of the Day - FreeBSD portupgrade

Posted by Ben Allen Sat, 05 Jan 2008 07:00:00 GMT

One complaint I’ve always had about FreeBSD port’s tree is upgrading outdated installed ports. Typically you need to go by hand and uninstall all the dependancies of a port, upgrade the port, and then reinstall all the dependancies. However, there are a few solutions for port upgrade management. The one I like the best is portupgrade that is available in the ports tree under /usr/ports/sysutils/portupgrade.

I have three typical usages:

Upgrade all ports, recursively reinstall any dependancies, and install any build dependancies

portupgrade -arR

Upgrade all ports, but ignore dependancies

portupgrade -a

Upgrade a single port, recursively reinstall any dependancies, install any build dependancies

portupgrade -rR <portname>

Ruby on Rails Development Stack on Mac OS X Leopard

Posted by Ron Valente Sun, 02 Dec 2007 07:02:00 GMT

Introduction

The main purpose of this howto is to offer instructions on how to setup a development stack for Mac OS X Leopard. There will be no beefy server backend so the web hosting portion of this tutorial will stop at mongrel. I will be using the built in rails stack and just updating the necessary packages. Now lets get this solid foundation patched and development ready. Enjoy.

Environment

Leopard ships with Ruby 1.8.6 patchlevel 36 with extra goodies that got merged in. The reason why Ruby was not the latest which is available today for download from Ruby-Lang is because it was released after the deadline. Do not fret the security vulnerabilities were patched. Since the version that ships with Leopard is “framework-ized” we will stick with that version and updating the Ruby on Rails installation around it.

Pre-Installed Gems

Below is a list of all the gems that come installed on a default Leopard install. The stack below is before anything has been done to a clean OS X install. We will use this as the base of our stack and build from here.

  • actionmailer (1.3.3)
  • actionpack (1.13.3)
  • actionwebservice (1.2.3)
  • activerecord (1.15.3)
  • activesupport (1.4.2)
  • acts_as_ferret (0.4.1)
  • capistrano (2.0.0)
  • cgimultiparteof_fix (2.2)
  • daemons (1.0.7)
  • dnssd (0.6.0)
  • fastthread (1.0)
  • fcgi (0.8.7)
  • ferret (0.11.4)
  • gem_plugin (0.2.2)
  • highline (1.2.9)
  • hpricot (0.6)
  • libxml-ruby (0.3.8.4)
  • mongrel (1.0.1)
  • needle (1.3.0)
  • net-sftp (1.1.0)
  • net-ssh (1.1.2)
  • rails (1.2.3)
  • rake (0.7.3)
  • RedCloth (3.0.4)
  • ruby-openid (1.1.4)
  • ruby-yadis (0.3.4)
  • rubynode (0.1.3)
  • sources (0.0.1)
  • sqlite3-ruby (1.2.1)
  • termios (0.9.4)

Updating Current Environment

First things first we need to update RubyGems is 0.9.5 which is fully supported by Leopard. To complete this step please run the following command in the terminal.

sudo gem update --system

Once this completes RubyGems will be fully patched and you will be ready to update the Ruby on Rails gems to their latest version.

Upgrading Installed Gems

Now that RubyGems is updated we are ready to update all the installed gems on the system.

sudo gem update

Once that has completed you will not have the latest version of stable rails as well as all the other fabulous gems that ship with Mac OS X.

Testing Your New and Updated Ruby on Rails Stack

cd ~/Sites
rails Test
cd Test
./script/server &

open http://localhost:3000

Adding Support For PostgreSQL Databases

In the next post on this topic I will be going over how to add support for PostgreSQL 8.2.5 as well as compiling PostgreSQL with DTrace support under Mac OS X.

Stay Tuned…

Changing Default Login Shell in Mac OS X Tiger/Leopard 1

Posted by Ron Valente Fri, 26 Oct 2007 05:54:00 GMT

To change your default login shell in Mac OS X Tiger and Leopard first we must find the options we have. This is done by

Prometheus$ cat /etc/shells 
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

Note: There are a few ways to actually go about changing the login shell, a few of these options are chpass, chsh, using dscl, etc.

For this tip we will use chpass and change our login shell to zsh.

Prometheus$ chsh -s /bin/zsh rvalente
Changing shell for rvalente.
Password for rvalente: 
Prometheus$

Enjoy using your new default shell

Older posts: 1 2