Running Redmine with Phusion Passenger
Phusion Passenger is a Ruby application server that was originally designed to run web applications (such as Redmine) that were built on the Ruby on Rails framework. Nowadays it has evolved, and besides Ruby applications, it supports Python and Node.js, making it a good candidate for various use cases.
This recipe is written for the Ubuntu 14.04 server.
Getting ready
Make sure that you have Apache and passenger
installed:
sudo apt-get install apache2 libapache2-mod-passenger
How to do it…
To configure Passenger, perform the following steps:
- Open
/etc/apache2/mods-available/passenger.conf
with your favourite editor, or usenano
:nano /etc/apache2/mods-available/passenger.conf
- Add the following line:
PassengerDefaultUser www-data.
- So, your
passenger.com
will look something like this:<IfModule mod_passenger.c> PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini PassengerDefaultRuby /usr/bin/ruby PassengerDefaultUser www-data </IfModule>
Tip
If you are using a different Ruby version installed via RVM, update the paths accordingly. Also replace
www-data
with your user.Please keep in mind that
PassengerDefaultUser
can be entered in your virtual server's config file, which you may need to edit manually for installations on shared hosting. - Create a symbolic link to the Redmine
public
folder from a web server's root folder like this:sudo ln -s /usr/share/redmine/public /var/www/html/redmine
- This link assumes that you installed Redmine through
apt-get
. If this is not the case and you installed it somewhere else such as/home/user/redmine
, then you must adjust your links according to your Redmine installation and www root, which may look something like this (for example):ln –s /home/user/redmine/public /home/user/public_html/redmine
- Make sure that
passenger
is enabled in Apache:sudo a2enmod passenger
- Modify
/etc/apache2/sites-available/000-default.conf
by typing the following:sudo nano /etc/apache2/sites-available/000-default.conf
- Add the following content near other
Directory
sections; if there are none, just make sure it's added before closing the</VirtualHost>
line:<Directory /var/www/html/redmine> RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on </Directory>
- Install
bundler
by typing the following:sudo gem update && sudo gem install bundler
- Finish the installation and restart Apache:
sudo touch /usr/share/redmine/Gemfile.lock sudo chown www-data:www-data /usr/share/redmine/Gemfile.lock sudo service apache2 restart
After restarting Apache, your Redmine installation should be ready to access by going to http://your_server/redmine
.
How it works…
First, you installed Apache web server and Phusion Passenger as a Ruby application server, which runs as an Apache module. Then you edited Apache's configuration file for Passenger by adding the default user to be www-data. After this, we created a symbolic link from Redmine's public directory to the web server's root directory. Then, we edited the virtual server's config to serve this particular directory with two Redmine-related configs – RailsBaseURI/redmine
, —which tells Ruby on Rails to access Redmine via the /redmine
subfolder, and PassengerResolveSymlinksInDocumentRoot
tells Passenger to follow symlink to find a Rails application through the symlink path. Instead of this, you could have written the following:
PassengerAppRoot /usr/share/redmine/
Redmine would work the same way.
There's more…
The best way to run Redmine or any other web-exposed software is to run it as a restricted user from its home directory and adjust Apache or any other web server to serve data from this directory. Running Redmine as a subdomain such as http://redmine.yoursite.com
, is done by creating an ordinary subdomain, and an Apache virtual host file for this subdomain with the settings that are provided in this recipe.
See also
If you stumble upon an error such as 403 (forbidden), error 500, or if you see Ruby code on the screen or the Passenger error screen, but you have followed the preceding steps exactly, refer to Troubleshooting Apache installations section in Chapter 9, Troubleshooting.
If you need to run Redmine as sub-uri, then take a look at http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI.