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

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.

see next reply, thanks

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 .

.

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 me@us.com
  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
        </Directory>

  ErrorLog /var/log/apache2/error.log
  LogLevel debug
</VirtualHost>

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

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,

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 me@us.com
  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
        </Directory>

  ErrorLog /var/log/apache2/error.log
  LogLevel debug
</VirtualHost>

[...]

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

Best,

No passenger. just Apache and Rails.

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

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.

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

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.

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

Thanks everybody!
Redmine is working correctly now. I am not certain what changed,

I am. You only used package management for rubygems :slight_smile: