Forum: Ruby on Rails Problem with images on Apache and Lighttpd

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Hans D. (Guest)
on 2006-06-04 23:42
Hello.

Since two days I am trying to set up two rails-apps on a vserver-host so
that I can access from work ;-)
I tried all I can imagine and what Google/MSN teached me: FastCGI, SCGI,
Lighttpd, Apache, Alias, Vhosts,....
But nothing really works. I am on Debian 3.1 with Ruby 1.8.4, Rails
1.1.2, FastCGI 2.4.0, mod_fastcgi 2.4.2, ruby_fcgi 0.8.6, ruby_gems
0.8.11, Apache 2.0.54, Lighttpd 1.4.11

At last I was really near my favorite solution. So that I can reach:
http://my.server.net/BlackJax
http://my.server.net/tracks

But both Apache AND Lighttpd showed the same problem: Images (and
partly) Stylesheets are not shown. The technique as such works fine.
Interesting: Both show the same errors (example from lighttpd-log,
apache shows the equivalent):
2006-06-04 20:57:10: (response.c.451) -- handling physical path
2006-06-04 20:57:10: (response.c.452) Path         :
/var/www/images/deck/2d.gif
2006-06-04 20:57:10: (response.c.492) -- file not found

I am using Fastcgi/Fcgid while getting this error, SCGI seemed even
messier to me (I only tried SCGI with Apache). For whatever reason it
seems that images are not taken from the (i.e.)
/opt/railsapps/BlackJax/public-folder, but from the servers doc-root.
btw: I did not miss to put
ActionController::AbstractRequest.relative_url_root = "/Blackjax"
at the end of environment.rb, I also checked .htaccess

Here the important part of my lighttp.conf:
-------
server.port = 80
server.modules           = ("mod_alias",  "mod_rewrite",
"mod_accesslog", "mod_fastcgi" )
server.document-root     = "/var/www/"
url.rewrite              = ( "^/$" => "index.html", "^([^.]+)$" =>
"$1.html" )

$HTTP["url"] =~ "^/BlackJax" {
  server.document-root = "/opt/railsapps/BlackJax/public/"
  alias.url = ( "/BlackJax" => "/opt/railsapps/BlackJax/public" )
  server.error-handler-404 = "/dispatch.fcgi"
  server.errorlog          =
"/opt/railsapps/BlackJax/log/lighttpd.error.log"
  accesslog.filename       =
"/opt/railsapps/BlackJax/log/lighttpd.access.log"
  server.indexfiles = ( "dispatch.fcgi", "index.html" )

  fastcgi.server = ( ".fcgi" =>
    ((
       "socket" => "/opt/railsapps/BlackJax/log/code.socket",
       "min-procs" => 2,
       "max-procs" => 2,
       "bin-path" =>  "/opt/railsapps/BlackJax/public/dispatch.fcgi",
       "bin-environment" => ( "RAILS_ENV" => "development" )
  )))
}
------------

And here the important part of my http.conf:
------------
NameVirtualHost *:80
FastCgiServer /var/www/BlackJax/public/dispatch.fcgi -initial-env
RAILS_ENV=development -processes 1 -idle-timeout 60
VirtualHost *>
    ServerName my.server.net
    DocumentRoot /var/www/

 RewriteCond %{REQUEST_URI} !^/BlackJax/public
 RewriteRule ^/BlackJax(/.*)?$   /BlackJax/public$1
    <Directory /var/www/BlackJax/public/>
        #ErrorLog        /var/www/BlackJax/log/error.log
        #CustomLog       /var/www/BlackJax/log/access.log combined
        SetEnv          RAILS_ENV development
        AddHandler fcgid-script .fcgi
        Options ExecCGI FollowSymLinks
        AllowOverride all
        Allow from all
        Order allow,deny
    </Directory>
-----------

I also tried to take away the rewrite-directives, but without success. I
am lost now... The only solution I can see would be to start two
lighttpd on different ports, cause that works :-(

any help is appreciated!

Best regards,

hans-dampf
Hans Dampf (Guest)
on 2006-06-10 10:52
Does nobody have an idea?

Thanks in advance

Hans Dampf
This topic is locked and can not be replied to.