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.
- relying on host header (
http://redmine.mydomain.com
) - 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.¶
- Change the base-uri of your stand-alone application.
- 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:- redirecting a web request to other URI
- 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.
Assuming you are deploying to
/redmine
:
- add and enable a new site called redmine on apache
- 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/
- fire up your Thin or mongrel server.
thin start -e production -a 127.0.0.1 -p3000
- restart apache
sudo apache2ctl graceful
Ready!¶
Just go open http://www.mydomain.com/redmine/
and you will be browsing your proxied redmine site.
IMPORTANT: remember the trailing slash! www.whatever.com/redmine/
WORKS www.whatever.com/redmine
Won't work.
As a workaround, just create a file called redmine.html on the the www root with a simple redirect.
i.e.:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Your Page Title</title> <meta http-equiv="REFRESH" content="3;url=/redmine/"></HEAD> <BODY> Redirecting in 3 seconds... </BODY> </HTML>
Just change the 3 of the content value to 0 if you want an instant redirect.
That's all folks. I hope it helped someone.
Updated by Carlos Troncoso over 12 years ago · 2 revisions