Ubuntu 11.04 with lighttpd

Popsch edited this page Feb 22, 2012 · 5 revisions

This is a guide to install tracks from source with lighttpd 1.4 and SSL on Ubuntu 11.04 (natty) with a sqlite database. Experienced people should find it easy to replace the sqlite adapter with a mysql adapter as you can see in this guide:

Getting Tracks Up

Make some directory for tracks:

sudo mkdir /opt/tracks

Get the source code

sudo git clone git://github.com/TracksApp/tracks.git /opt/tracks/tracks
cd /opt/tracks/tracks

Install the necessary files for rails:

sudo apt-get install rails
sudo apt-get install rake
sudo apt-get install libfcgi-ruby1.8

Comment out zentest and hoe in the Gemfile and then get some additional ruby gems:

## edit the Gemfile first
sudo gem install bundler
sudo /var/lib/gems/1.8/bin/bundle install

If you need only either mysql or sqlite for Tracks, then you will have to edit the Gemfile and comment out either gem "sqlite3" or gem "mysql".

Create your config/database.yml file. It should look similar to the following. Note: make sure that the www-data user can read the sqlite database file. You might want to choose better paths for your database.

test: &TEST
  adapter: sqlite3
  database: ":memory:"

  adapter: sqlite3
  database: /tmp/tracks-production.sq3

  adapter: sqlite3
  database: /tmp/tracks-development.sq3    

  <<: *TEST

  <<: *TEST

Create your config/site.yml file from the template config/site.yml.tmpl. Initialize the database:

rake db:migrate RAILS_ENV=production
rake db:migrate RAILS_ENV=development ## in case you want help out later

Check whether you can run the server locally:

sudo ./scripts/server -e production

Check whether the server is running by going to http://localhost:3000. Terminate the process once you know it's working.

Getting lighttpd running

Install the necessary packages

apt-get install lighttpd spawn-fcgi lighttpd-mod-magnet

Enable the mods for lighted

lighttpd-enable-mod fastcgi
lighttpd-enable-mod magnet
lighttpd-enable-mod access
lighttpd-disable-mod javascript-alias

Follow the description of running rails applications with lighttpd. Note you need to either configure or disable the javascript-alias mod, because otherwise lighttpd will search in the wrong directory for the javascript files. You can easily use spawn-fcgi for running rails applications as spawn-fcgi comes with a package in Ubuntu: http://redmine.lighttpd.net/wiki/1/LighttpdOnRails

Get the fcgi bridge working with rails

Create a startup file called run-tracks.sh for tracks based on this template:http://redmine.lighttpd.net/projects/spawn-fcgi/repository/entry/trunk/doc/run-rails. Use www-data for the user and the group.

Configure the system so the www-data user can access the system:

mkdir /opt/tracks/tracks/log
chown -R www-data:www-data /opt/tracks/tracks/public

Test whether the script is working by starting it:

chmod +x /opt/tracks/run-tracks.sh
sudo -u www-data /opt/tracks/run-tracks.sh

Getting https running

Check whether you have ssl compiled into lighttpd with lighttpd -v. It should mention ssl. Then following this guide to enable ssl: http://redmine.lighttpd.net/wiki/1/HowToSimpleSSL

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.