Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Ruby On Rails App in a subdirectory under Apache

I've got apache2.2 on windows. I'm trying to serve both subversion (/svn) and redmine (/redmine). I have svn running fine with this config:

<Location /svn>
  DAV svn
  SVNParentPath C:/svn_repository
  ...
</Location>

This is working great--my svn users can hit http://mybox/svn just fine.

Now I want to add another directory for a rails app (RedMine):

I followed the advice in this question to setup a mongrel server and have apache proxy clients through to it. It works fine if I make it the root--but I'm having trouble making it in a subdirectory:

<Location /redmine>
  ProxyPass http://localhost:3000/
  ProxyPassReverse http://localhost:3000/
</Location>

Any suggestions?

like image 742
Michael Haren Avatar asked Jan 22 '09 21:01

Michael Haren


People also ask

How do I add my own code to a Rails application?

You can configure your own code through the Rails configuration object with custom configuration under either the config.x namespace, or config directly.

Where can I find discussion about Ruby on rails documentation?

And last but not least, any kind of discussion regarding Ruby on Rails documentation is very welcome on the rubyonrails-docs mailing list .

What does it mean to configure rails?

In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The configuration file config/application.rb and environment-specific configuration files (such as config/environments/production.rb) allow you to specify the various settings that you want to pass down to all of the components.

How do I change the path to Ruby in Apache passenger?

Replace /path-to-ruby with the Ruby command that you obtained in Determine the Ruby command that Passenger should use. When you are done, restart Apache: (Depending on your operating system, the right command may be apache2ctl instead of apachectl .)


1 Answers

Here's what I had to change:

I removed the trailing slash:

<Location /redmine>
  ProxyPass http://localhost:3000
  ProxyPassReverse http://localhost:3000/
</Location>

And in my rails app:

# added to end of file C:\redmine\config\environment.rb
ActionController::AbstractRequest.relative_url_root = "/redmine"

Now it's working!


I wasn't completely happy with this approach--I ran into some redirect issues. This is another attempt which seems to be working well so far.

  • Fast CGI and Fast CGI without VirtualHosts
  • Tuning Fast CGI

This second approach seems better.


UPDATE:

As noted in the comments, for more recent apps running on Rails 2.3.2+, use this instead:

config.action_controller.relative_url_root = '/redmine'

I put it in the new additional_environment.rb file.

like image 153
Michael Haren Avatar answered Oct 26 '22 22:10

Michael Haren