Project

General

Profile

HowTo Install Redmine in a sub-URI » History » Version 11

Zack s, 2012-08-01 10:31

1 3 Jean-Philippe Lang
h1. HowTo Install Redmine in a sub-URI
2 1 Jean-Baptiste Barth
3 2 Jean-Baptiste Barth
This page explains how to run Redmine in a subdirectory of your site, for instance @http://www.mysite.com/redmine/@ ; in such a case, you can feel lost because the classic Redmine install does not work directly, and the links to css or javascript files seem to be broken. In this page, we assume you want to run Redmine under "/redmine/" subdirectory of your site.
4 1 Jean-Baptiste Barth
5 6 Luca Pireddu
h2.  Using Redmine::Utils (preferred solution)
6
7
Add the following line at the bottom of your config/environment.rb
8
9
<pre>
10
Redmine::Utils::relative_url_root = "/redmine"
11
</pre>
12
13
Then restart your application.
14
15
h2. Using Rails features
16 1 Jean-Baptiste Barth
17
Add the following line at the end of your config/environment.rb :
18
<pre>
19
ActionController::AbstractRequest.relative_url_root = "/redmine"
20 4 Michael Vance
</pre>Rails will then prefix all links with "/redmine". It can be considered as the simplest, cleanest and most flexible solution. Then restart your application. In more recent versions of Rails the class hierarchy has changed slightly and you will need to use
21
<pre>
22
ActionController::Base.relative_url_root = "/redmine"
23 5 Michael Vance
</pre>for the class name.
24 1 Jean-Baptiste Barth
25
h2. Using Mongrel features
26
27 2 Jean-Baptiste Barth
If you run Redmine under Mongrel server, you can alternatively use the "--prefix" option of Mongrel :
28 1 Jean-Baptiste Barth
<pre>
29 2 Jean-Baptiste Barth
mongrel_rails start --prefix=/redmine
30 7 Tiemo Vorschuetz
</pre>
31
_*Mongrel_rails service "--prefix" directive does NOT work with Rails 2.3.x*
32
To fix this issue create a file config/initializers/patch_for_mongrel.rb [name of file can be anything]:_
33
<pre>
34
# Fix for mongrel which still doesn't know about Rails 2.2's changes, 
35
# We provide a backwards compatible wrapper around the new
36
# ActionController::base.relative_url_root,
37
# so it can still be called off of the actually non-existing
38
# AbstractRequest class.
39
40
module ActionController
41
  class AbstractRequest < ActionController::Request
42
    def self.relative_url_root=(path)
43
      ActionController::Base.relative_url_root=(path)
44
    end
45
    def self.relative_url_root
46
      ActionController::Base.relative_url_root
47
    end
48
  end
49
end
50
#
51
# Thanks to http://www.ruby-forum.com/topic/190287
52
</pre>
53
54
You may not run Mongrel on port 80 : if you have an Apache server on the same host, and you run Mongrel on port 8000, you can use the following Apache config to redirect (with Apache's mod_proxy enabled) :
55 1 Jean-Baptiste Barth
<pre>
56
ProxyPass /redmine http://localhost:8000/redmine
57
ProxyPassReverse /redmine http://localhost:8000/redmine
58
</pre>
59
60
h2. Using Passenger (aka mod_rails) features
61
62 9 Zack s
If you run Redmine under Apache web server with Phusion Passenger module, you can follow "this guide":http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri ; please note it won't work correctly on some versions of Passenger or some Linux distributions.
63 1 Jean-Baptiste Barth
64
h2. With a reverse proxy
65
66
If you have an Apache webserver in front of it (with mod_proxy enabled), or an Apache reverse proxy on another machine, you can run Redmine on a specific port and use this kind of config so it appears to be running in a subdirectory :
67
<pre>
68
ProxyPass /redmine http://real-redmine-server.localdomain:3000/
69
ProxyPassReverse /redmine http://real-redmine-server.localdomain:3000/
70 2 Jean-Baptiste Barth
</pre>See Apache official documentation to adapt it.
71 1 Jean-Baptiste Barth
72
73 2 Jean-Baptiste Barth
h2. Old versions of Redmine and Rails
74 1 Jean-Baptiste Barth
75 2 Jean-Baptiste Barth
If you run a very old version of Redmine (don't know exactly which ones), maybe your version of Rails' ActionController does not support the "relative_url_root" mentionned above. Then you can look at "this page":https://www.riscosopen.org/wiki/documentation/pages/Running+Rails+applications+from+subdirectories/versions/16 to reproduce the same behaviour, but it is NOT a very good idea in most cases, you should consider upgrading Redmine.
76
77 1 Jean-Baptiste Barth
h2. References
78
79 8 Zack s
If this page did not answered your problems, you can see #2508 or "this thread":http://www.redmine.org/boards/2/topics/2244.
80 10 Zack s
81
Windows : Configuring Ruby On Rails App in a subdirectory under Apache - http://stackoverflow.com/a/470973/663172
82 11 Zack s
83
Configuring ruby on rails Action Controller - http://edgeguides.rubyonrails.org/configuring.html#configuring-action-controller