Set up apache and passenger

kej edited this page Aug 22, 2012 · 2 revisions

Ubuntu 12.04 LTS

  • Install Apache2, postgres, curl, git, etc.
sudo apt-get install ...

and then for the postgres gems:

sudo apt-get install libpq-dev #needed for pg gem
  • Create new user (without pwd) sudo useradd passenger --system

  • Add passenger to www-data group

  • With postgres (sudo su postgres) user create new database user passenger with new password

  • create lang for postgres

  • create database for passenger user

  • For new passenger user install rvm (note: using rvm is only recommended for systems which are routinely updated as a possible security update has to be installed manually. Alternatively one can use the brightbox ruby-ng packages for ubuntu)

  • install ruby version wanted with rvm

  • Give passenger ownership to /var/www

  • checkout project from github: How to download the code

  • setup project (database.yml, configuration.yml, database import etc.)

Setting up a production server

  • with selected ruby and gemset install bundler

  • bundle install for project

  • gem install passenger --no-ri --no-rdoc

  • passenger-install-apache2-module

  • Install all necessary packages via sudo (passenger tells you what is missing)

sudo apt-get install libcurl4-openssl-dev
sudo apt-get install apache2-prefork-dev
sudo apt-get install libapr1-dev
sudo apt-get install libaprutil1-dev
  • passenger-install-apache2-module again

  • passenger tells you what to add to your apache config file (LoadModule, PassengerRoot and PassengerRuby).

Apache setup

As we are running apache with passenger to serve our rails applications first of all a site has to be set up for apache. This has to be done as superuser or with sufficient rights. This is done by setting up a config file inside the

sudo nano /etc/apache2/sites-available/fundiv

directory. This directory contains (ideally) one file per site or group of sites. Each config file can be activated or deactivated seperately thus taking the corresponding sites online or offline. For a passenger rails setup one has to follow the instructions given by the modrails website. In our case we put each site under an own subdomain. The "deploying to a virtual host section" on modrails is of interest. What follows is the basic entry necessary to setup a new site. Additionally of course any directives (such as rewrites) may be used.

<VirtualHost *:80>
  DocumentRoot /var/www/production/fundiv/public
  RailsEnv production
  <Directory /var/www/production/fundiv>
      AllowOverride all
      Options -MultiViews
  • Disable default site sudo a2dissite default

  • Enable apache site configuration sudo a2ensite befdata

  • Reload Apache configuration sudo /etc/init.d/apache2 reload

The server is reachable via:> befdata2:xx> befdata2:xx> befdata2:xx> befdata2:xx und sind über virtuellen Host über Flipper "ge-reverse-proxied" und zeigen auf atlantis...:xxxx.

Die ci.-Adresse ist dagegen eine echte DNS-Subdomain. Weiß nicht, was das für Vor- und Nachteile hat.

The dev server is reachable via