Apache2.2 + what to get Rails

Me: not experienced with Rails or Ruby,

Problem: Ubuntu 9.04 server in my shop …couldn’t get Apache2.2 +
Passenger + Rails to work for Redmine. (No answer at Redmine list and
I don’t think its their problem anyway). Also couldn’t get Apache2.2
and just Rails to work, though some people said it would. Webrick
works.

Goal: run Redmine on a server that also runs PHP and other web
services. No port numbers in URL. Separate VirtualHost for Rails from
PHP apps.

Error: no matches for route…“path to various css and js
files” … the site actually works very very slowly, but the
graphics and layouts and javascripts don’t.

Main question: Is it impossible to get Apache 2.2 to work with Rails
without Passenger or Mongrel Cluster? Indirect evidence on Rails
documentation makes it sound like you need Mongrel for the routes that
don’t go to an actual file?

Tried: many differing Apache configs, fastcgi vs fcgid, with or
without Passenger, other Rails apps ( simple hello world works in
present config) reset permissions and ownership, checked paths,
scratched head, made coffee…

Ideas?

thanks
John

On Wed, Sep 30, 2009 at 5:42 AM, John [email protected] wrote:

services. No port numbers in URL. Separate VirtualHost for Rails from

Tried: many differing Apache configs, fastcgi vs fcgid, with or
without Passenger, other Rails apps ( simple hello world works in
present config) reset permissions and ownership, checked paths,
scratched head, made coffee…

Ideas?

Can you “pastie” some configs and some errors? I have Apache 2.2.13 +
Rails + Redmine + PHP running on a home server with Arch Linux, so
either is one of your configurations or your packages.
How did you installed all your (this problem related) software pieces?

Cheers.


Leonardo M…
There’s no place like ~

John wrote:

Me: not experienced with Rails or Ruby,

Problem: Ubuntu 9.04 server in my shop …couldn’t get Apache2.2 +
Passenger + Rails to work for Redmine. (No answer at Redmine list and
I don’t think its their problem anyway). Also couldn’t get Apache2.2
and just Rails to work, though some people said it would. Webrick
works.

Goal: run Redmine on a server that also runs PHP and other web
services. No port numbers in URL. Separate VirtualHost for Rails from
PHP apps.

Error: no matches for route…“path to various css and js
files” … the site actually works very very slowly, but the
graphics and layouts and javascripts don’t.

Main question: Is it impossible to get Apache 2.2 to work with Rails
without Passenger or Mongrel Cluster? Indirect evidence on Rails
documentation makes it sound like you need Mongrel for the routes that
don’t go to an actual file?

There are other ways, but Passenger is by far the easiest – it should
be about as easy as setting up PHP. Have you checked the Passenger docs
and confirmed that your vhost configuration is correct?

Tried: many differing Apache configs, fastcgi vs fcgid, with or
without Passenger,

Passenger should be all you need – no Mongrel or FastCGI.

other Rails apps ( simple hello world works in
present config)

Then perhaps this is a Redmine issue.

The reset permissions and ownership, checked paths,
scratched head, made coffee…

And unfortunately we can’t really help you, since you haven’t provided
any error messages or config files to diagnose…
Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Ideas?

thanks
John

Yeah thanks. I didn’t post up apache configs because I wanted first to
know which path, Passenger vs no Passenger vs Mongrel cluster to take,
so I could focus on one, and then ask better questions. I’ll start
over tomorrow when I am back in the office and re-load Passenger and
see what happens.

other Rails apps ( simple hello world works in
present config)

Then perhaps this is a Redmine issue.

well, here’s my logic: a simple hello world rails app works, but it
doesn’t have complex routes or stylesheets or javascript files, and
those are failing. When I try Webrick Redmine works correctly,
therefore something or a lack of something is interfering with
Ruby’s ability ( or Rails?) to route to these files when I use
Apache .

.

see next reply, thanks

OK I am back with some better data.
I have Apache2.2 set up with a VirtualHost for the Rails site and
loading fcgid not fastcgi. Apache is sending all requests to the base
URL to dispatch.fcgi and the Redmine site checks the db and loads very
slowly without any CSS or Javascript. The Redmine error message is “no
route matches…”

  1. Apache virtualhost:
    <VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName redmine…com
    DocumentRoot /var/www/redmine/public/

     <Directory "/var/www/redmine/public">
    

    Options Indexes +ExecCGI FollowSymLinks
    AddHandler fcgid-script .fcgi
    Order allow,deny
    Allow from all

ErrorLog /var/log/apache2/error.log
LogLevel debug

  1. The .htaccess file in the public directory ( /var/www/redmine/
    public):
    Options +FollowSymLinks +ExecCGI

##################################
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

<IfModule !mod_fcgid.c>

RewriteRule ^(.*)$ dispatch.cgi [QSA,L]


#########################################

  1. the error messages from production.log in redmine:

ActionController::RoutingError (No route matches “/plugin_assets/
redmine_issues_group/stylesheets/stylesheet.css” with
{:method=>:get}):
and for “/stylesheets/jstoolbar.css”
and for “/javascripts/application.js” and so on…

  1. The routes.rb file from redmine ( note these routes work under
    WeBrick)

ActionController::Routing::Routes.draw do |map|

Add your own custom routes here.

The priority is based upon order of creation: first created ->

highest priority.

Here’s a sample route:

map.connect ‘products/:id’, :controller => ‘catalog’, :action =>

‘view’

Keep in mind you can assign values other than :controller

and :action

Allow Redmine plugins to map routes and potentially override them

Rails.plugins.each do |plugin|
map.from_plugin plugin.name.to_sym
end

map.home ‘’, :controller => ‘welcome’
map.signin ‘login’, :controller => ‘account’, :action => ‘login’
map.signout ‘logout’, :controller => ‘account’, :action => ‘logout’

map.connect ‘wiki/:id/:page/:action’, :controller => ‘wiki’, :page
=> nil
map.connect ‘roles/workflow/:id/:role_id/:tracker_id’, :controller
=> ‘roles’, :action => ‘workflow’
map.connect ‘help/:ctrl/:page’, :controller => ‘help’
#map.connect ‘:controller/:action/:id/:sort_key/:sort_order’

map.connect ‘issues/:issue_id/relations/:action/:id’, :controller =>
‘issue_relations’
map.connect ‘projects/:project_id/issues/:action’, :controller =>
‘issues’
map.connect ‘projects/:project_id/news/:action’, :controller =>
‘news’
map.connect ‘projects/:project_id/documents/:action’, :controller =>
‘documents’
map.connect ‘projects/:project_id/boards/:action/:id’, :controller
=> ‘boards’
map.connect ‘projects/:project_id/timelog/:action/:id’, :controller
=> ‘timelog’, :project_id => /.+/
map.connect ‘boards/:board_id/topics/:action/:id’, :controller =>
‘messages’

map.with_options :controller => ‘repositories’ do |omap|
omap.repositories_show ‘repositories/browse/:id/*path’, :action =>
‘browse’
omap.repositories_changes ‘repositories/changes/:id/
*path’, :action => ‘changes’
omap.repositories_diff ‘repositories/diff/:id/*path’, :action =>
‘diff’
omap.repositories_entry ‘repositories/entry/:id/*path’, :action =>
‘entry’
omap.repositories_entry ‘repositories/annotate/:id/*path’, :action
=> ‘annotate’
omap.repositories_revision ‘repositories/
revision/:id/:rev’, :action => ‘revision’
end

map.connect ‘attachments/:id’, :controller => ‘attachments’, :action
=> ‘show’, :id => /\d+/
map.connect ‘attachments/:id/:filename’, :controller =>
‘attachments’, :action => ‘show’, :id => /\d+/, :filename => /./
map.connect ‘attachments/download/:id/:filename’, :controller =>
‘attachments’, :action => ‘download’, :id => /\d+/, :filename => /.
/

Allow downloading Web Service WSDL as a file with an extension

instead of a file named ‘wsdl’

map.connect ‘:controller/service.wsdl’, :action => ‘wsdl’

Install the default route as the lowest priority.

map.connect ‘:controller/:action/:id’
end

################

thanks,
John

John wrote:

OK I am back with some better data.
I have Apache2.2 set up with a VirtualHost for the Rails site and
loading fcgid not fastcgi. Apache is sending all requests to the base
URL to dispatch.fcgi and the Redmine site checks the db and loads very
slowly without any CSS or Javascript. The Redmine error message is “no
route matches…”

  1. Apache virtualhost:
    <VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName redmine…com
    DocumentRoot /var/www/redmine/public/

     <Directory "/var/www/redmine/public">
    

    Options Indexes +ExecCGI FollowSymLinks
    AddHandler fcgid-script .fcgi
    Order allow,deny
    Allow from all

ErrorLog /var/log/apache2/error.log
LogLevel debug

[…]

Are you using Passenger? If so, then you don’t need fcgi. Please read
the Passenger documentation.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

No passenger. just Apache and Rails.

On Oct 1, 12:46 pm, Marnen Laibow-Koser <rails-mailing-l…@andreas-

John wrote:
[…]

other Rails apps ( simple hello world works in
present config)

Then perhaps this is a Redmine issue.

well, here’s my logic: a simple hello world rails app works, but it
doesn’t have complex routes or stylesheets or javascript files,

It does have stylesheets and JS. The default welcome page in a new
Rails app uses both.

and
those are failing. When I try Webrick Redmine works correctly,
therefore something or a lack of something is interfering with
Ruby’s ability ( or Rails?) to route to these files when I use
Apache .

.

Again, I think this is an issue with Redmine, or at least with the
interaction between Redmine and Passenger (which is strange – I’ve used
them together with no problem). You might check in Redmine’s forums.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

You ARE going to need SOMETHING that will execute the rails
environment. Apache does NOT have the required environment out-of-the-
box to run rails. You will need something like:

fcgi
thin
mongrel
passenger (recommended)

I am using fcgi and Redmine is accessing the database and building the
page, but it can’t route to some files.

As stated above I am not experienced with Ruby or Rails so I can’t
tell when Rails is doing something or Ruby is, but I am assuming
database access is all Ruby and therefore Rails must be working
partially. But somethings wrong and maybe thats it… I got here
because I couldn’t get Passenger to work…but if the consensus is
for using passenger I’ll go back to it, I just got tired of changing
too many things at once.

thanks,
john

Thanks Leonardo, I did do some installs using Ubuntu-Debian packages,
but I think I’ll follow your advice on using only the gems install,
also using Passenger. P is still not working, so I’ll strip it and
Rails out and start over.

I don’t agree about top-posting, to me bottom-posting is perverse, but
will gladly do whatever the list style is. Most Linux lists do top-
posting but I ain’t religious about it.

John

John wrote:

Thanks Leonardo, I did do some installs using Ubuntu-Debian packages,
but I think I’ll follow your advice on using only the gems install,
also using Passenger. P is still not working, so I’ll strip it and
Rails out and start over.

I don’t agree about top-posting, to me bottom-posting is perverse, but
will gladly do whatever the list style is.

Um, how is it “perverse” to follow conversational order – that is, to
do things like

What OS do you use,
Mac OS X
and what version?
Snow Leopard.

That’s how it would be in a conversation. It is perverse to do anything
else, I think.

Most Linux lists do top-
posting

I doubt that. I think most people just don’t care to fight with e-mail
clients that make top-posting easier.

but I ain’t religious about it.

Nor I, usually. But top-posting is harder to follow, especially if
(like me) you prefer the greater clarity of going line by line.

John

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

I’ve run into random problems before when trying to get passenger to
work. They were dependent on the particular environment I was
installing to and generally had to do with the ways I like to
customize my ruby/rails environment (so probably not worth me
posting). That said, the investment of time is really worth the
payoff, in my opinion. Once you have it set up and working, it reduces
a lot of the hassle of managing your rails applications, and handles
multiple concurrent requests without you having to worry about it.

That said, particularly if you’re on a machine with limited resources
(like a cheap, small VM) or non-standard ruby/rails installations,
there will be up-front costs of time and effort in order to get your
installation going.

On Oct 2, 11:33 am, Marnen Laibow-Koser <rails-mailing-l…@andreas-

On Fri, Oct 2, 2009 at 12:26 AM, John [email protected] wrote:

too many things at once.

I’d strongly recommend you to use passenger, and it should work out of
the box.
If it doensn’t, you should describe your rails environment and how you
installed, because I’ve experienced problems with debian(like)?
packages.
You should install only rubygems from Ubuntu packages, then install
the gem rubygems-update, and then run update_rubygems (check if it’s
in the path), and after that install all your gems via gem and not via
apt-get/aptitude/synaptic.
After that install passenger, build the apache module, create your
apache config files, define your vhost, and should work. That’s how
I’ve done it in serveral computers, including Ubuntu, Debian and a
couple of Arch Linux.

Hope it helps.

Cheers.

PS: Please, try to avoid top-posting, is really hard to follow the
conversation with that.


Leonardo M…
There’s no place like ~

On Oct 2, 11:33 am, Marnen Laibow-Koser <rails-mailing-l…@andreas-
s.net> wrote:

but I ain’t religious about it.

Nor I, usually. But top-posting is harder to follow, especially if
(like me) you prefer the greater clarity of going line by line.

sure Marnen, I have no quibble with that and do it all the time, but
I find it awkward to scroll through a long quote that I myself wrote
or have already read just to get to the meat&potatoes. My biggest
complaint is misuse of digests and failure to trim quotes. Non-
computer lists are terrible at staying OT…whoops I digress!

  • ripping everything out and starting over with rubygems, Rails and
    Passenger.

John

Thanks everybody!
Redmine is working correctly now. I am not certain what changed, as
my settings look like they did before, so I must have the magic
combination. Passenger is nowloaded via the gem instead of manually
before. For the sake of the next newbie, here’s what I did:

starting with a 9.04 Ubuntu server, running Apache2.2 and Mysql and
Ruby in the usual way, with build tools installed, and root access:

install the Redmine app following their directions

apt-get install rubygems1.8
run “gem install rubygems-update”
run “update_rubygems” note: this will clean out your gems
run “gem install rails --VERSION=2.1.2” required by Redmine app
run “gem install mysql”
run “gem install passenger”
run “passenger-install-apache2-module” follow instructions

restart Apache

####################

heres the relevant part of my default configuration file from apache2/
sites-available:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/
passenger-2.2.5/ext/apache2/mod_passenger.so

<VirtualHost *:80>
ServerAdmin [email protected]
ServerName redmine.example.com
DocumentRoot /var/www/redmine/public/
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5
PassengerRuby /usr/bin/ruby1.8

    <Directory "/var/www/redmine/public/">
Options Indexes +ExecCGI FollowSymLinks
            Order allow,deny
            Allow from all
    </Directory>

ErrorLog /var/log/apache2/error.log
LogLevel debug

#############

and heres the .htaccess file…

Options +FollowSymLinks +ExecCGI
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
RewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

ErrorDocument 500 “

Application error

Rails application
REDMINE failed to start properly”

##############

and here’s what gem says I have:

*** LOCAL GEMS ***

actionmailer (2.3.4, 2.1.2)
actionpack (2.3.4, 2.1.2)
activerecord (2.3.4, 2.1.2)
activeresource (2.3.4, 2.1.2)
activesupport (2.3.4, 2.1.2)
fastthread (1.0.7)
mysql (2.8.1)
passenger (2.2.5)
rack (1.0.0)
rails (2.1.2)
rake (0.8.7)
rubygems-update (1.3.5)

########################

and heres what dpkg says I have for ruby:

root@dizzy:/var/www/redmine/public# dpkg -l |grep ruby
libapache-ruby1.8
1.2.6-2
libapache2-mod-ruby
1.2.6-2
libbreakpoint-ruby1.8
0.5.1-2
libbuilder-ruby1.8
2.1.2-1
libcmdparse2-ruby1.8
2.0.2-2
libdaemons-ruby1.8
1.0.10-2
liberb-ruby
4.2
libfcgi-ruby1.8
0.8.7-4.1
liblog4r-ruby1.8
1.0.5-7
libmmap-ruby1.8
0.2.6-3
libmocha-ruby1.8
0.9.0-1
libncurses-ruby1.8
1.1-3
libopenssl-ruby1.8
1.8.7.72-3ubuntu0.1
libreadline-ruby1.8
1.8.7.72-3ubuntu0.1
libredcloth-ruby1.8 3.0.99.0.svn.
20060519-1
libruby
4.2
libruby1.8
1.8.7.72-3ubuntu0.1
libsqlite3-ruby1.8
1.2.4-2
libxml-simple-ruby
1.0.11-2
rake
0.8.1-3
rdoc
4.2
ruby
4.2
ruby1.8
1.8.7.72-3ubuntu0.1
ruby1.8-dev
1.8.7.72-3ubuntu0.1
ruby1.8-examples
1.8.7.72-3ubuntu0.1
rubygems-doc
1.3.1-1
rubygems1.8
1.3.1-1

####################

thanks again.

On Fri, Oct 2, 2009 at 6:55 PM, John [email protected] wrote:

Thanks everybody!
Redmine is working correctly now. I am not certain what changed,
I am. You only used package management for rubygems :slight_smile:

apt-get install rubygems1.8

   DocumentRoot /var/www/redmine/public/
   LogLevel debug

rack (1.0.0)
1.2.6-2
liberb-ruby
1.1-3
libsqlite3-ruby1.8
1.8.7.72-3ubuntu0.1

thanks again.


Leonardo M…
There’s no place like ~