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

**URL:** <https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070>\
**Category:** Deployment\
**Created:** [December 13, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070 "2007-12-13T20:21:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/1 "2007-12-13T20:21:11Z")

</div>

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](http://127.0.0.1:8000)  
BalancerMember [http://127.0.0.1:8001](http://127.0.0.1:8001)

\<VirtualHost \*:8080\>  
ServerAdmin removed\_email\_address@domain.invalid  
ServerName [webapp.example.com](http://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]

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 8:55pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/2 "2007-12-13T20:55:26Z")

</div>

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](http://www.silverrack.com)

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 9:40pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/3 "2007-12-13T21:40:18Z")

</div>

On Dec 13, 1:54 pm, “Dave Stevenson” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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://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]

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 10:45pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/4 "2007-12-13T22:45:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 10:52pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/5 "2007-12-13T22:52:05Z")

</div>

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](http://www.silverrack.com)

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 10:57pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/6 "2007-12-13T22:57:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 13, 2007, 11:23pm UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/7 "2007-12-13T23:23:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mememe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/977dab/32.png) [@mememe](https://www.ruby-forum.com/u/mememe)\
**Post date:** [December 14, 2007, 12:54am UTC](https://www.ruby-forum.com/t/cant-seem-to-load-css-and-images-after-first-deployment/123070/8 "2007-12-14T00:54:02Z")

</div>

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.
