-
Notifications
You must be signed in to change notification settings - Fork 0
InstallGuideForUbuntu
How to install Calagator with Ruby Enterprise Edition on Ubuntu Jaunty.
This is a draft document
This is a step-by-step install guide for setting up Calagator on a new Ubuntu 9.04 (Jaunty) server. There are several options for installing Ruby and Rails, of course, but in this case we will use Phusion's Ruby Enterprise Edition (REE). REE is a straightforward way to get up and running quickly and is recommended for production servers. It creates a self-contained environment for Ruby, Rails and gems which co-exists happily with your system Ruby.
Please review current software requirements for Calagator before you begin.
For the purposes of this guide, we'll be working with:
- Git 1.6.0.4
- Java 1.6.0_13
- Ruby Enterprise Edition 1.8.6 (Apache 2, Ruby 1.8.6, Passenger 2.2.2, Ruby Gems 1.3.2)
- SQLite3
Calagator uses SQLite by default. Other databases, including MySQL and Postgres, are not officially supported at this time.
Before doing anything else, we'll make sure that our package manager is current and we have the base packages needed to build and compile.
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install build-essential gcc autoconf libtool
Calagator is available via git, the version control software. While the version of Git installed by the Ubuntu package manager is a bit outdated, it's sufficient for our purposes. Git tutorials are available at the git website: http://git-scm.com/
$ sudo apt-get install git-core
...
$ git --version
git version 1.6.0.4
Java is required for solr, which provides the muscle for Calagator's search. Download the appropriate file from http://java.org. We will install java to /usr/local/java, so we make the installer executable, create our installation directory and then run the installer from that location.
$ cd ~/src
$ wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=29214
$ sudo chmod a+x ~/src/jre-REALLY-LONG-NAME.bin
$ sudo mkdir /usr/local/java
$ cd /usr/local/java
$ sudo ~/src/jre-REALLY-LONG-NAME.bin
Make sure that Java is accessible, either by adding it to your path or by symlinking it.
$ sudo ln -s /usr/local/java/jre1.6.0_13/bin/java /usr/bin/java
..
$ java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02, mixed mode)
Ruby Enterprise Edition creates a self-contained environment for Ruby, Rails and Gems which can be installed in parallel with your system Ruby. The installer will walk you through the setup and explain clearly what needs to be done if any prerequisites aren't met, as well as giving you the commands needed to install dependencies.
There are a few packages which are needed, so install those first. (Alternatively, run the installer and let it to tell you what is needed.) The sqlite3 and libsqlite3-dev packages are required for sqlite3-ruby on Ubuntu.
$ sudo apt-get install zlib1g-dev libssl-dev libreadline5-dev
$ sudo apt-get install sqlite3 libsqlite3-dev
Determine which download file you need from http://www.rubyenterpriseedition.com/download.html and download, unpack, and install. In this case, we choose to keep the default installation directory at /opt/ruby-enterprise-1.8.6-20090421.
$ wget http://rubyforge.org/frs/download.php/55511/ruby-enterprise-1.8.6-20090421.tar.gz
$ tar xzvf ruby-enterprise-1.8.6-20090421.tar.gz
$ sudo ./ruby-enterprise-1.8.6-20090421/installer
If you get an error about required dependencies, simply follow the instructions and re-run the installer. MySQL and Postgres may fail to install. This is okay, as we will be using SQLite for our database. MySQL and Postgres are not officially supported by Calagator at this time.
But with any luck, the installation succeeds with the following message:
Ruby Enterprise Edition is successfully installed!
If want to use Phusion Passenger (http://www.modrails.com) in combination
with Ruby Enterprise Edition, then you must reinstall Phusion Passenger against
Ruby Enterprise Edition, as follows:
/opt/ruby-enterprise-1.8.6-20090421/bin/passenger-install-apache2-module
Make sure you don't forget to paste the Apache configuration directives that
the installer gives you.
According to the instructions, reinstall Phusion Passenger against Ruby Enterprise Edition.
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/passenger-install-apache2-module
Some requirements may not be found. In our case, Apache 2 and the Apache Portable Runtime and Runtime Utility development headers were not present. The installer gives appropriate directions.
Installation instructions for required software
* To install Apache 2:
Please run apt-get install apache2-mpm-prefork as root.
* To install Apache 2 development headers:
Please run apt-get install apache2-prefork-dev as root.
* To install Apache Portable Runtime (APR) development headers:
Please run apt-get install libapr1-dev as root.
* To install Apache Portable Runtime Utility (APU) development headers:
Please download it from http://httpd.apache.org/
(APR Utility is an integrated part of Apache.)
So install the requirements:
$ sudo apt-get install apache2-mpm-prefork apache2-prefork-dev libapr1-dev
The APR development headers can be downloaded from http://apr.apache.org/download.cgi and installed (by default) to /usr/local.
$ cd ~/src
$ wget http://www.eng.lsu.edu/mirrors/apache/apr/apr-1.3.3.tar.gz
$ tar xvzf apr-1.3.3.tar.gz
$ cd apr-1.3.3
$ ./configure
$ make
$ sudo make install
Having satisfied the requirements for Passenger, re-run the installer.
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/passenger-install-apache2-module
...
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/passenger-2.2.2
PassengerRuby /opt/ruby-enterprise-1.8.6-20090421/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
Suppose you have a Ruby on Rails application in /somewhere. Add a virtual host
to your Apache configuration file, and set its DocumentRoot to
/somewhere/public, like this:
<VirtualHost *:80>
ServerName www.yourhost.com
DocumentRoot /somewhere/public # <-- be sure to point to 'public'!
</VirtualHost>
And that's it!
Rather than edit the Apache configuration file, we'll create a "passenger" file within apache2/conf.d and copy the Passenger code there. Apache will look at this file automatically on start.
$ cd /etc/apache2/conf.d
$ sudo nano passenger
... copy/paste passenger code ...
Add the virtualhost entry to /etc/apache2/httpd.conf. In our case, we'll create our Calagator project in /var/www/calagator, but you may choose another location. "example" will be the domain for our project.
$ cd /etc/apache2
$ sudo nano httpd.conf
... copy/paste virtualhost directive ...
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www/calagator/public
</VirtualHost>
At this point we have Ruby Enterprise Edition installed and configured to use Phusion Passenger, which will expect our project to be located at /var/www/calagator. You may want to add /opt/ruby-enterprise-1.8.6-20090421/bin to your path so that you can run gem or rake commands directly.
The current version of the Ruby Enterprise Edition installer includes Rails 2.3.2, but Calagator requires Rails 2.1.2, so we need to add the earlier version of Rails. It's okay to have multiple versions of Rails installed.
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install rails -v 2.1.2 --no-ri --no-rdoc
A Google Maps API key is needed in order to geocode venues and events. This is a simple process, and optional. Your key will be tied to your domain name or the url by which you access your instance. See more notes in Calagator's config/geocoder_api_keys.yml.example.
Calagator is available via git. Move to your project location and clone the Calagator repository.
$ cd /var/www
$ sudo git clone git://github.com/calagator/calagator.git
Now is a good time to make configuration changes to Calagator.
- Review the settings and required gems in config/environment.rb
- Change email addresses in secrets.yml and config/initializers/exception_notification_setup.rb.
- Add your Google maps API key to config/geocoder_api_keys.yml
Running "rake spec" from the project directory will take you down the road of installing required gems. You can install them manually.
$ cd /var/www/calagator
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install hpricot --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install htmlentities --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install vpim --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install rubyzip --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install rspec --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install rspec-rails --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install facets --no-ri --no-rdoc
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/gem install has_many_polymorphs -v 2.12 --no-ri --no-rdoc
At this point, running "rake spec" from within the calagator directory should output a message about pending migrations, something like:
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/rake spec
(in /var/www/calagator)
You have 21 pending migrations:
1 CreateEvents
2 CreateVenues
3 CreateSources
4 AddDetailedFieldsToVenue
5 AddEndTimeToEvents
6 AddSourceIdToEvents
8 AddSourceIdToVenues
9 AddDuplicateOfColumnToVenues
10 AddDuplicateOfColumnToEvents
11 ChangeLatLongType
12 AddSourceReimport
13 ChangeEndTimeToDuration
14 RemoveFormatTypeFromSource
15 CreateUpdates
16 RemoveNextUpdateFromSource
20080604210521 ConvertTimesToUtc
20080705163959 ChangeDurationToEndTime
20080705164959 CreateTagsAndTaggings
20081011181519 CreateVersionedEvents
20081011193124 CreateVersionedVenues
20081115190515 AddRruleToEvents
Run "rake db:migrate" to update your database then try again.
If rake complains about missing gems instead, install them. Otherwise, migrate the development database.
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/rake db:migrate db:test:prepare
Migrate the production database, since Passenger will run the application in production mode.
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/rake db:migrate RAILS_ENV="production"
Additionally, change the permissions on the databases and optionally change the owner of Calagator (we'll use www-data) so that Passenger isn't running as root. This needs confirmation
$ sudo chmod 666 /var/www/calagator/db/development.sqlite
$ sudo chmod 666 /var/www/calagator/db/production.sqlite
$ sudo chown -R www-data:www-data /var/www/calagator
Remember that you must start solr before running Calagator.
$ cd /var/www/calagator
$ sudo /opt/ruby-enterprise-1.8.6-20090421/bin/rake solr:start
Start (or restart) Apache:
$ sudo /etc/init.d/apache2 start
At this point, your Calagator should be visible at the IP number of your box or the domain name you've specified, being served by Apache on port 80. If anything is misconfigured, you may see a Passenger error instead. Check the Apache logs (/var/log/apache2/) and/or the Calagator logs (calagator/log).
The Ruby Enterprise Edition installer may fail to install sqlite3-ruby.
Installing sqlite3-ruby...
/opt/ruby-enterprise-1.8.6-20090421/bin/ruby /opt/ruby-enterprise-1.8.6-20090421/bin/gem install -r --no-rdoc --no-ri --no-update-sources --backtrace sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/opt/ruby-enterprise-1.8.6-20090421/bin/ruby extconf.rb
checking for fdatasync() in -lrt... yes
checking for sqlite3.h... no
make
make: *** No rule to make target `ruby.h', needed by `sqlite3_api_wrap.o'. Stop.
Gem files will remain installed in /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
Fix: Confirm that sqlite3 and libsqlite3-dev are installed.
CONTENT UPDATES NEEDED This document should updated to be relevant to Ubuntu 14.04.