Installing: Apache / Passenger

Install Passenger



Ubuntu 8.10 Instructions:

Add the source for brightbox.net which holds the passenger package.

    sudo sh -c 'echo "deb http://apt.brightbox.net hardy main" >  \
      /etc/apt/sources.list.d/brightbox.list'
    sudo sh -c 'wget -q -O - http://apt.brightbox.net/release.asc | apt-key add -'
    sudo apt-get update
    sudo apt-get install libapache2-mod-passenger

Note: if you don’t install the brightbox repository you will get a phusion error because you’ll have an old version of the gem installed

Skip to apache–passenger#config

Debian Lenny

Two sources are required, one for tryphon.org and one for backports.

 sudo sh -c 'echo "deb http://www.backports.org/debian lenny-backports main contrib non-free" > /etc/apt/sources.list.d/backports.list'
 sudo sh -c 'wget -O - http://backports.org/debian/archive.key | apt-key add -'
 sudo sh -c 'echo "deb http://debian.tryphon.org stable main contrib" > /etc/apt/sources.list.d/tryphon.list'
 sudo sh -c 'wget -q -O - http://debian.tryphon.org/release.asc | sudo apt-key add -'

 sudo apt-get update
 sudo apt-get -t lenny-backports install libapache2-mod-passenger librack-ruby

Skip to apache–passenger#config

Fedora 12

Fedora doesn’t have a package source for passenger, just make sure the apache header files are installed, then install passenger from a gem.

 sudo yum install httpd-devel

Skip to apache–passenger#config

OS X

If you are using cider, you may need to run the command as root with your .cider.profile :

 cd ~
 sudo -i
 source .cider.profile
 passenger-install-apache2-module

Then past the apache config into /etc/apache2/other/passenger.conf

To edit your default apache virtual host, edit /etc/apache/extra/httpd-vhosts.conf and remove the comment to include the file in /etc/apache2/httpd.conf

You may need to add an additional override to overcome default apache2 permissions:

      <Directory />
         AllowOverride None
         Order Deny,Allow
      </Directory>

Other operating systems

See the passenger site for more information

Gem Install

Depending on your distribution, you may have to take a few extra steps to install the correct gems necessary for Webiva. Webiva requires gems dependent on rubygems-update version 1.3.xx. However because of a little hiccup with rubygems-update version 1.2 it cannot be upgraded directly. The steps to fix this are quick. Since Fedora 12 has version 1.3.5, you can skip to Install Passenger Gem section

First of all, make sure the latest version is uninstalled:

sudo gem uninstall rubygems-update --version=1.3.5

Install the older but still newer version:

sudo gem uninstall rubygems-update --version=1.3.1

Run the gem updater

sudo update_rubygems

Now install the latest:

sudo gem uninstall rubygems-update --version=1.3.5

Rerun the gem updater

sudo update_rubygems

The gem will build a package for your version of apache. Make sure you have the header/development apache files installed for this to work.

For Ubuntu 8.1 or Debian Lenny that would be:

apache2-threaded-dev        
sudo apt-get install apache2-threaded-dev 

or

apache2-prefork-dev
sudo apt-get install 

Install Passenger Gem

Now install the gem:

sudo gem install passenger

Debian / Ubuntu : Make sure that gems are in your path

export PATH=$PATH:/var/lib/gems/1.8/bin

Now compile the passenger/apache module

sudo passenger-install-apache2-module

Debian / Ubuntu : or directly if you have path troubles

sudo /var/lib/gems/1.8/bin/passenger-install-apache2-module

Add the passenger module load lines into the apache config

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.9/ext/apache2/mod_passenger.so 
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.9 
PassengerRuby /usr/bin/ruby1.8

Apache2 configuration

The easiest way to install webiva is to install it as the default virtual host.

This way you can add domains and won’t need to modify your apache2 configuration every time you add on a domain.

Create a virtual host like the one below (make sure the document root points to the webiva/public directory)

sudo vi /etc/apache2/sites-available/default

If you are creating a new virtual host in Debian or ubuntu, remember to symlink the site to the enabled directory.

sudo a2ensite webiva

Either modify or replace with:

 <VirtualHost *:80>
   ServerName mywebiva.com
   ServerAlias www.mywebiva.com
   DocumentRoot /path/to/your/webiva/public/directory

   # Optional - set site to run as a specific user
   #  PassengerDefaultUser user 

   # Optional - set to production or development as necessary
   #  RailsEnv production 

   # Get rid of favicon.ico - use a <link .. in <head>..</head> instead
   Redirect 404 /favicon.ico
   <Location /favicon.ico>
     ErrorDocument 404 "No favicon"
   </Location>

   # We don't want any user uploaded scripts to be executed in the public directory
   # This should be the public/system directory of your webiva install
   <Directory "path/to/your/webiva/public/system/directory">
         Options FollowSymLinks
         AllowOverride Limit
         Order allow,deny
         Allow from all
         <IfModule mod_php5.c>
          php_admin_flag engine off
        </IfModule>
        AddType text/plain .html .htm .shtml .php .php3 .phtml .phtm .pl
   </Directory>
 </VirtualHost>

Fedora puts a default config file called welcome.conf in /etc/httpd/conf.d/, be sure to remove it or changes its options so your site will work

Don’t forget to start up the background server process

   ./script/background.rb start

(Not if you are running in development mode, you may need to instead run:)

   RAILS_ENV=development ./script/background.rb start

If you don’t have a RAILS_ENV environment variable set

Finally, restart apache and you should be good to go:

Check the configuration

note that debian and ubuntu use apache2ctl while fedora uses apachectl

   sudo apache2ctl -t     

If everything looks good, then:

   sudo apache2ctl restart

Bring up a browser and confirm that you can access your site.