HowTo Install Redmine on subdirectory (sub-URI) on Apache

Submitted by erick on Sat, 08/19/2017 - 19:37

HowTo Install Redmine on subdirectory (sub-URI) on Apache

Your Issue

You are probably running ruby 1.9, rails 3, apache, passenger and you want to run redmine.
Unfortunately, it's not rails-3 ready, and passenger can only run one ruby version.
So you've got two choices.

  1. relying on host header (http://redmine.mydomain.com)
  2. sub-URI deployment (http://www.mydomain.com/redmine/)

This tutorial will focus on choice 2. Sub-URI deployment.

Dependencies

I'll assume you got redmine running stand-alone with mongrel or better even, with Thin

Roadmap.

  1. Change the base-uri of your stand-alone application.
  2. Proxy it through apache.

Change the base-uri of your stand-alone application.

Quite simple actually.
Open up config/environment.rb and add at the very end of the file the following line:

Redmine::Utils::relative_url_root = "/redmine"


Of course, you can choose whatever subdirectory you want it to run.

 

If you try to test your app on localhost:3000/redmine, all your css an js will show up broken.
In my setup, the routes to the js and css were actually rewriten to point to /redmine/javascript and /redmine/stylesheets, but the problem is that... the files aren't there!. As they are served staticly over public/*, rails rewrite actually breaks them, but, that is exactly what we want.
Don't worry. It'll be fixed on the next step.

Proxy it through apache.

Reverse proxy usually has two parts:

  1. redirecting a web request to other URI
  2. rewriting the returned HTML and header to match the sub-URI

On step N°1, a request to http://www.mydomain.com/redmine is sent to http://www.mydomain.com:5001
On step N°2, the HTML is rewritten to change any reference of http://www.mydomain.com:5001/ back to http://www.mydomain.com/redmine.

But as all url references are relative, we never see the http part on an rails html, just the "/wharever", and we already reference the sub-URI with the relative_url_root line we added to environment.rb, so we can actually skip step N°2.

We just need to get redirected.
Assuming you are deploying to /redmine:

  1. add and enable a new site called redmine on apache
  2. edit the file and fill it up with this

    <Proxy *> Order deny,allow Allow from all </Proxy> ProxyRequests Off ProxyPass /redmine/ http://127.0.0.1:3000/

  3. fire up your Thin or mongrel server. thin start -e production -a 127.0.0.1 -p3000
  4. restart apache sudo apache2ctl graceful