Archive

Posts Tagged ‘Linux’

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 ‘http://rubygems.org’

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

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

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

 

production:
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/mod_passenger.so
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
</Directory>
</VirtualHost>

 

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 = SyslogLogger.new

# 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 = “http://assets.example.com&#8221;

# 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
end

 

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

Linux Management Software

November 30, 2010 Leave a comment

I have been on the look out for the best server management software for Linux specifically. I think I finally found it.

Red Hat has put out an open source project called Spacewalk, and it is the best Red Hat project out there by far. It brings together cobbler, augeas and other projects into a great package.

I’m still doing a lot of the initial configuration but I’m very impressed. I mostly needed it for monitoring and configuration management rather then package management and server deployments but I’m sure I will be using those features soon enough. It is worth the time to install and try. According the site it also supports Solaris and that debian support is coming.

I will be posting my experience with this project as I keep using it. My only problem with this project is that the postgres support is still very much in an alpha to beta state. I can tell you right now as soon as the postgres support improves I will be moving off Oracle.

Spacewalk – My favorite Red Hat Project

February 15, 2010 Leave a comment

I’ve been playing with spacewalk on and off for a couple of months, I haven’t touched it since 0.8* I just updated to 0.9* and there are enough improvements I want to say it is ready for any production Linux shop.
Download it and give it a try, it takes some time to setup but once you do it will be worth it!
I may put up my Virtualbox VM on my personal FTP server, let please post a comment on this post if you are interested!

Categories: Uncategorized Tags: , ,

WebYast – An awesome addition to YaST

December 9, 2009 Leave a comment

I just finished installing WebYast on a SLES 11 virtual machine and so far I like it.  It is a wonderful Ruby based application that very extendable.

A web client of YaST is something the SUSE distro has need for sometime in my opinion.  This has a lot of potential, I would like to be able to one day use a single YaST client, web or fat, to manage several SUSE servers, whether they are SLE or openSUSE.  Novell has a good tool to manage multiple Linux servers Zenworks Linux Management, but for those small scale server deployments I would rather have a good open source solution rather then pay the money for Zenworks.

Screenshot of WebYast and to follow.

Categories: Linux, SUSE Tags: , , , ,