Posts Tagged ‘active admin’

How to setup Active Admin on Ubuntu 11.10 with MySQL, Passenger and Apache

January 5, 2012 Leave a comment

I had a colleague that I do work or a occasionally and he had a customer approach him asking for assistance setting up an open source Ruby on Rails 3 project called Active Admin.  I agreed to help him out and after working through this with the limited documentation available I decided to write up the steps I took to install this project.  I installed this on Ubuntu Server 11.10 base install, so I didn’t install anything but the default base packages.  I’m also going to put a guide up for Fedora 16 and if I have time I’ll get it working on RHEL 6.2 as well.


The first thing I did was install Ruby 1.9.2 and make

sudo apt-get install ruby1.9.2-full make

I know the packages say it is ruby1.9.1 but after it is installed run “ruby -v” you’ll see it is 1.9.2

After make and ruby are installed we can start to build our ruby environment.  I started off installing rails and rack.

sudo gem install rails rack -v 1.3.6

Active Admin recommends 1.3.5 but I just installed 1.3.6.  If you forget to add the version number for rack it will also install 1.4.0 as well as 1.3.6.  If you do you will need to uninstall it.

sudo gem uninstall rack (select 1.4.0 to uninstall, it should be the second option)

Next lets make a place to put the project.  Made a directory called /var/rails but you can put it anywhere.  Just as long as apache can read it.  I just made sure it was owned by my current user and had permissions of 775 (you can adjust these permissions this is just what I set it to and when I used 755 it didn’t work)

Also the user you are logged in as will have a hidden directory in it’s home directory called .gem.   It gets created by root and is owned by root.  So you will need to change the ownership to the user you are logged in as.

Active Admin will not install without the sqlite3 gem so you will need to install the sqlite dev libraries (sudo apt-get install libsqlite3-dev)

In this example we are going to use mysql so lets get the packages we need

sudo apt-get install libmysqld-dev libmysqlclient-dev mysql-server

Follow the prompt and set your MySQL root password

Login to mysql (mysql -uroot -p)

In MySQL create your databases for Active Admin just called them activeadmindev, activeadmintest, activeadminprod

You can create your own users in MySQL if you like for each database in my database.yml example (upcoming) I’m just using root which is not recommended!

Now we are can create our environment.  In /var/rails (or where ever you are going to put Active Admin) run:

rails new activeadmin –skep-gemfile

I skipped the gemfile because I ran into all kinds of issues with the default.  The only gems I have in my gemfile are activeadmin sass-rails meta_search mysql and sqlite3.  You gem should go in the project home directoy in my case /var/rails/activeadmin/Gemfile

This is what it should look like:

source ‘’

gem ‘activeadmin’
gem ‘sass-rails’
gem ‘meta_search’, ‘>= 1.1.0’
gem ‘mysql’
gem ‘sqlite3’


Now that we have our gemlist file ready we can install Active Admin.  In the project home run rails generate active_admin:install

After it is installed we need to modify the /var/rails/activeadmin/config/database.yml file so it will use MySQL here is what my sample looks like

adapter: mysql
database: activeadmindev
username: root
password: activeadmin
host: localhost

adapter: mysql
database: activeadmintest
username: root
password: activeadmin
host: localhost


adapter: mysql
database: activeadminprod
username: root
password: activeadmin
host: localhost

Once this is saved we can run rake, you can skip the dev and test if you like but using the dev is a good way to make sure everything is working before you move on to installing apache:

rake db:migrate  (this will populate the development database)

rake db:mirgate RAILS_ENV=production (this will populate the production database)

If you populated the development database you can now test and see if you did everything right by running ‘rails server’.  If it comes up with out any errors point a web browser to your server http://activeadmin:3000/admin.  The username is admin@example and the password is simply password.


Now that we know everything works, we can get apache and passenger installed.  Passenger is going to need some development packages to build the plugin so we will just install everything with apache.  After everything is installed I recommend you just stop apache (sudo /etc/init.d/apache2 stop).  You will need to do that anyway after you install passenger

sudo apt-get install apache2 apache2-dev build-essential libcurl4-openssl-dev zlib1g-dev

Now we install passenger using passenger-install-apache2-module.  It will prompt you if you’d like to install it and it will compile the plugin.  If you missed any packages it requires it will prompt you to install them and give you the command to install the missing packages.  Easy right?

Lets get passenger’s apache config done.  First is /etc/apache2/conf.d/passenger.conf and it needs to contain:

LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-3.0.11/ext/apache2/
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-3.0.11
PassengerRuby /usr/bin/ruby1.9.1

Now we need to create the config for activeadmin.  I named mine /etc/apache2/conf.d/activeadmin.conf and it looks like this:

<VirtualHost *:80>
ServerName activeadmin
DocumentRoot /var/rails/activeadmin/public
<Directory /var/rails/activeadmin/public>
AllowOverride all
Options -MultiViews


Just make sure your DocumentRoot points to the public folder in the project home directory.

Before you start apache modify your production environment file (/var/rails/activeadmin/config/environments/production.rb) so that config.assets.compile is equal to true.

Here is what my production.rb file looks like:

Activeadmin::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# Code is not reloaded between requests
config.cache_classes = true

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# Disable Rails’s static asset server (Apache or nginx will already do this)
config.serve_static_assets = false

# Compress JavaScripts and CSS
config.assets.compress = true

# Don’t fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

# Generate digests for assets URLs
config.assets.digest = true

# Defaults to Rails.root.join(“public/assets”)
# config.assets.manifest = YOUR_PATH

# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = “X-Sendfile” # for apache
# config.action_dispatch.x_sendfile_header = ‘X-Accel-Redirect’ # for nginx

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# See everything in the log (default is :info)
# config.log_level = :debug

# Use a different logger for distributed setups
# config.logger =

# Use a different cache store in production
# config.cache_store = :mem_cache_store

# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = “;

# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )

# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false

# Enable threaded mode
# config.threadsafe!

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify


After that you can start apache and login!  Have fun!