Can't seem to load css and images after first deployment

I’ve deployed a rails app (using Capistrano) to an a server running
apache and mongrel_cluster.

I am able to get to my page, but what I see is basically my page
without stylesheet referred and all the images missing. Can someone
point me in the right direction?

The following is a copy of my .conf file:

<Proxy balancer://mongrel_cluster_for_webapp>
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001

<VirtualHost *:8080>
ServerAdmin [email protected]
ServerName webapp.example.com

DocumentRoot /srv/www/htdocs/webapp/current/public

# don't lose time with IP address lookups
HostnameLookups Off

# needed for named virtual hosts
UseCanonicalName Off

# configures the footer on server-generated documents
ServerSignature On

<Directory "/srv/www/htdocs/webapp/current/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

RewriteEngine On

# Check maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]

# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]

# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]

# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ 

balancer://mongrel_cluster_for_webapp%{REQUEST_URI}
[P,QSA,L]

I usually try a couple of things to determine where the problem might
be:

  1. connect to mongrel directly and see if everything is working (lynx
    localhost:3000 for example). If everything is loading fine hitting
    mongrel directly, then chances are it’s in your apache config.
  2. Check apache config - I looked over yours and it appears to be the
    same
    setup I use. You do have it using port 8080, which is interesting.
  3. View source of your pages, and make sure the references are pointing
    to
    the right files, and that the url it generated is correct. Try and hit
    those pages directly in the browser (copy and paste into your address
    bar)

Good luck,
Dave
http://www.silverrack.com

On Dec 13, 1:54 pm, “Dave Stevenson” [email protected] wrote:

  1. connect to mongrel directly and see if everything is working (lynx
    localhost:3000 for example). If everything is loading fine hitting
    mongrel directly, then chances are it’s in your apache config.

I don’t have lynx installed, but I did use curl and they load up just
fine. Like so:

$ curl -I http://localhost:8001/images/rails.png
HTTP/1.1 200 OK
Connection: close
Date: Thu, 13 Dec 2007 20:14:08 GMT
ETag: “47571126-6fb-f80655”
Last-Modified: Wed, 05 Dec 2007 20:59:18 GMT
Content-Type: image/png
Content-Length: 1787

  1. Check apache config - I looked over yours and it appears to be the same
    setup I use. You do have it using port 8080, which is interesting.

I’m running two separate instances of apache. First one uses port 80
and that’s being used actively as a production server. The second is
to test deployment and get things working before rolling it out onto
the first server.

  1. View source of your pages, and make sure the references are pointing to
    the right files, and that the url it generated is correct. Try and hit
    those pages directly in the browser (copy and paste into your address bar)

Had tried this already, and this definitely isn’t working.

Here’s what my rewrite log shows when trying to load rails.png (while
loading the standard rails welcome page):

[rid#825d910/initial] (2) init rewrite engine with requested uri /
images/rails.png
[rid#825d910/initial] (3) applying pattern ‘^.$’ to uri ‘/images/
rails.png’
[rid#825d910/initial] (4) RewriteCond: input=‘/srv/www/htdocs/webapp/
current/public/system/maintenance.html’ pattern=‘-f’ => not-matched
[rid#825d910/initial] (3) applying pattern ‘^/$’ to uri ‘/images/
rails.png’
[rid#825d910/initial] (3) applying pattern ‘^([^.]+)$’ to uri ‘/images/
rails.png’
[rid#825d910/initial] (3) applying pattern '^/(.
)$’ to uri ‘/images/
rails.png’
[rid#825d910/initial] (4) RewriteCond: input=‘/srv/www/htdocs/webapp/
current/public//images/rails.png’ pattern=‘!-f’ => not-matched
[rid#825d910/initial] (1) pass through /images/rails.png

[rid#8261970/initial/redir#1] (2) init rewrite engine with requested
uri /error/HTTP_FORBIDDEN.html.var
[rid#8261970/initial/redir#1] (3) applying pattern ‘^.$’ to uri ‘/
error/HTTP_FORBIDDEN.html.var’
[rid#8261970/initial/redir#1] (4) RewriteCond: input=‘/srv/www/htdocs/
webapp/current/public/system/maintenance.html’ pattern=‘-f’ => not-
matched
[rid#8261970/initial/redir#1] (3) applying pattern ‘^/$’ to uri ‘/
error/HTTP_FORBIDDEN.html.var’
[rid#8261970/initial/redir#1] (3) applying pattern ‘^([^.]+)$’ to uri
‘/error/HTTP_FORBIDDEN.html.var’
[rid#8261970/initial/redir#1] (3) applying pattern '^/(.
)$’ to uri ‘/
error/HTTP_FORBIDDEN.html.var’
[rid#8261970/initial/redir#1] (4) RewriteCond: input=‘/srv/www/htdocs/
webapp/current/public//error/HTTP_FORBIDDEN.html.var’ pattern=‘!-f’ =>
matched
[rid#8261970/initial/redir#1] (2) rewrite ‘/error/
HTTP_FORBIDDEN.html.var’ → ‘balancer://mongrel_cluster_for_webapp/
error/HTTP_FORBIDDEN.html.var’
[rid#8261970/initial/redir#1] (2) forcing proxy-throughput with
balancer://mongrel_cluster_for_webapp/error/HTTP_FORBIDDEN.html.var
[rid#8261970/initial/redir#1] (1) go-ahead with proxy request
proxy:balancer://mongrel_cluster_for_webapp/error/
HTTP_FORBIDDEN.html.var [OK]

So, I was able to get this to work by routing all requests, whether
static or non-static to the cluster. Whether it’s the right thing to
do is another question entirely, so I don’t consider this solved just
yet.

After going the rewrite log files, I saw that the RewriteCond in the
following snippet ought to be commented out the page to pop up
correctly, like so:

Redirect all non-static requests to cluster

#RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster_for_webapp%{REQUEST_URI}
[P,QSA,L]

Because when it came to images, javascript files, and stylesheets, it
would not match the !-f (file does not exist) part of the condition
and it would pass through.

I guess the next step is to find out why apache is not able to find
these files.

A shot in the dark - does your apache user have permissions to the
images
and css folders?

Dave
Affordable VPS Hosting
http://www.silverrack.com

So, I was able to get this to work by routing all requests, whether
static or non-static to the cluster. Whether it’s the right thing to
do is another question entirely, so I don’t consider this solved just
yet.

After going the rewrite log files, I saw that the RewriteCond in the
following snippet ought to be commented out the page to pop up
correctly, like so:

Redirect all non-static requests to cluster

#RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster_for_webapp%{REQUEST_URI}
[P,QSA,L]

Because when it came to images, javascript files, and stylesheets, it
would not match the !-f (file does not exist) part of the condition
and it would pass through.

I guess the next step is to find out why apache is not able to find
these files.

So, I was able to get this to work by routing all requests, whether
static or non-static to the cluster. Whether it’s the right thing to
do is another question entirely, so I don’t consider this solved just
yet.

After going the rewrite log files, I saw that the RewriteCond in the
following snippet ought to be commented out the page to pop up
correctly, like so:

Redirect all non-static requests to cluster

#RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_cluster_for_webapp%{REQUEST_URI}
[P,QSA,L]

Because when it came to images, javascript files, and stylesheets, it
would not match the !-f (file does not exist) part of the condition
and it would pass through.

I guess the next step is to find out why apache is not able to find
these files.

First, please excuse those duplicate posts that came from me. I don’t
know how that happened.

To answer your question, permissions are properly set for the entire
filesystem under documentroot.

The httpd error log gives me:

“Symbolic link not allowed or link target not accessible: /srv/www/
htdocs/webapp/current”

Strange.

For hell of it, I added the following inside my vhost settings

<Directory "/srv/www/htdocs/webapp/current">
            Options FollowSymLinks
            AllowOverride None
            Order allow,deny
            Allow from all
</Directory>

…but that didn’t make a difference.

I also double-checked that nothing was overriding this in default-
server.conf and that uid.conf had the right group name assigned.