Project

General

Profile

Apache fcgi deployment: 404 errors

Added by Sean Lynch over 13 years ago

I have an application that I'm trying to deploy on apache with fcgi. Assuming my application is called 'myapp' I'm trying to set it up so I can get to it at a url like http://myapp.mydomain.com/myapp.wt

My apache virtual host is set up as follows:

<VirtualHost *:80>
             ServerName myapp.mydomain.com
             DocumentRoot /var/www/myapp
             <Directory /var/www/myapp>
                        AllowOverride all
                        Allow from all
                        options ExecCGI
             </Directory>
</VirtualHost>

I moved the wt resources directory to /var/www-resources/wt/.

The resource for my application including the css and img directories were moved to /var/www-resources/myapp/

Next I changed/added the following relevant lines in my wt_config.xml.

<server>
    <application-settings location="*">
        .
        .
        .
        <property name="resourcesURL">/var/www-resources/wt/resources/</property>
        .
        .
        .
    </application-settings> 

    <application-settings location="/var/www/myapp/myapp.wt">
        <properties>
            <property name="favicon">/var/www-resources/myapp/img/favicon.ico</property>
            <property name="appRoot">/var/www-resources/myapp/</property>
        </properties>
    </application-settings>
</server>

I thought that this would be everything I needed to do to set this up but when I go to the URL I get a login page but with no styles or images. The following 404 errors are in my apache log:

[26/Dec/2011:10:05:17 -0500] "GET /var/www-resources/wt/resources/webkit-transitions.css HTTP/1.1" 404 530 "http://myapp.mydomain.com/myapp.wt" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
[26/Dec/2011:10:05:17 -0500] "GET /var/www-resources/myapp/css/myapp.css HTTP/1.1" 404 518 "http://myapp.mydomain.com/myapp.wt" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
[26/Dec/2011:10:05:17 -0500] "GET /var/www-resources/wt/resources/form.css HTTP/1.1" 404 522 "http://myapp.mydomain.com/myapp.wt" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
[26/Dec/2011:10:05:17 -0500] "GET /var/www-resources/wt/resources//themes/default/wt.css HTTP/1.1" 404 528 "http://myapp.mydomain.com/myapp.wt" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
[26/Dec/2011:10:05:17 -0500] "GET /img/myappTitleImg.png HTTP/1.1" 404 511 "http://myapp.mydomain.com/myapp.wt" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"

[26/Dec/2011:10:05:17 -0500] "GET /var/www-resources/myapp/img/favicon.ico HTTP/1.1" 404 524 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"

Replies (5)

RE: Apache fcgi deployment: 404 errors - Added by Koen Deforche over 13 years ago

Hey,

I guess it's because you specified the "file system path" of the wt resources folder for the "resourcesURL" property.

A URL is relative to the DocumentRoot (which you've configured as "/var/www/myapp"

You should thus make sure that you move the resources inside your DocumentRoot, e.g. /var/www/myapp/wt/resources/, and you only need to specify the location relative to "/var/www/myapp", e.g. "/wt/resources/".

Regards,

koen

RE: Apache fcgi deployment: 404 errors - Added by Sean Lynch over 13 years ago

Thanks Koen.

I moved everything where it should be and it works. I didn't realize that everything is relative to the document root specified in the apache virtual host.

Now, however, the app works but I'm getting new errors. If I leave the browser for a while, when I come back to the page it tells me there is a 500 error. I refreshed the page and the error log gives me the following:

[2011-Dec-28 20:38:47.583018] 11212 - [info] "wtfcgi: spawned dedicated process for wugEbh4WkrIv4TrA: pid=11386"
[2011-Dec-28 20:38:47.625377] 11386 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/myapp/myapp.wt')"
[2011-Dec-28 20:38:47.626673] 11386 - [info] "Auth::GoogleService: not configured: OAuth: no 'google-oauth2-redirect-endpoint' property configured"
[2011-Dec-28 20:38:47.626871] 11386 - [info] "WServer/wtfcgi: initializing dedicated wtfcgi session process"
[2011-Dec-28 20:38:47.684526] 11386 - [info] "Wt: session created (#sessions = 1)"
[2011-Dec-28 20:38:47.685210] 11386 [/myapp.wt wugEbh4WkrIv4TrA] [info] "WEnvironment: UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
create table "user" (
  "id" serial primary key ,
  "version" integer not null,
  "num_entries" integer not null,
  "last_entry" timestamp
)

NOTICE:  CREATE TABLE will create implicit sequence "user_id_seq1" for serial column "user.id"
[2011-Dec-28 20:38:47.703090] 11386 [/myapp.wt wugEbh4WkrIv4TrA] [info] "Using existing database"
[2011-Dec-28 20:38:47.710972] 11386 [/myapp.wt wugEbh4WkrIv4TrA] [info] "WebRequest: took 27.033ms"
[2011-Dec-28 20:38:47.779081] 11212 - [info] "wtfcgi: spawned dedicated process for Ue9sJlntJzcyRYMQ: pid=11398"
[2011-Dec-28 20:38:47.821164] 11398 - [info] "config: reading Wt config file: /etc/wt/wt_config.xml (location = '/var/www/myapp/myapp.wt')"
[2011-Dec-28 20:38:47.822466] 11398 - [info] "Auth::GoogleService: not configured: OAuth: no 'google-oauth2-redirect-endpoint' property configured"
[2011-Dec-28 20:38:47.822670] 11398 - [info] "WServer/wtfcgi: initializing dedicated wtfcgi session process"
[2011-Dec-28 20:38:47.880636] 11398 - [info] "Wt: session created (#sessions = 1)"
[2011-Dec-28 20:38:47.881332] 11398 [/myapp.wt Ue9sJlntJzcyRYMQ] [info] "WEnvironment: UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
[2011-Dec-28 20:38:47.881807] 11398 [/myapp.wt Ue9sJlntJzcyRYMQ] [info] "Wt: signal from dead session, sending reload."
[2011-Dec-28 20:38:47.882822] 11398 [/myapp.wt Ue9sJlntJzcyRYMQ] [info] "WebRequest: took 2.947ms"
[2011-Dec-28 20:38:47.883140] 11398 [/myapp.wt Ue9sJlntJzcyRYMQ] [info] "Wt: session destroyed (#sessions = 0)"
read: Connection reset by peer
[Wed Dec 28 20:38:48 2011] [warn] [client 68.44.191.169] mod_fcgid: error reading data, FastCGI server closed connection, referer: http://myapp.mydomain.com/myapp.wt/myapp
[Wed Dec 28 20:38:48 2011] [error] [client 68.44.191.169] Premature end of script headers: myapp.wt, referer: http://myapp.mydomain.com/myapp.wt/myapp
[2011-Dec-28 20:38:48.891686] 11212 - [info] "wtfcgi: caught SIGCHLD: pid=11398, stat=0"
[2011-Dec-28 20:38:48.891901] 11212 - [info] "wtfcgi: deleting session: Ue9sJlntJzcyRYMQ"
[2011-Dec-28 20:38:49.862379] 11212 - [info] "wtfcgi: shutdown (caught SIGTERM)"

Any ideas on what causes this would be appreciated.

Thanks

-Sean

RE: Apache fcgi deployment: 404 errors - Added by Koen Deforche over 13 years ago

Hey,

This doesn't look too bad --- I suspect that the refresh worked as expected too ?

The reason for the 500, we should be able to infer from the log files preceding the refresh ?

Regards,

koen

RE: Apache fcgi deployment: 404 errors - Added by Sean Lynch over 13 years ago

I think it has something to do with how I update the internal path. When I hit refresh it brings me back to the main page, but the url listed is still listed as the page that I was on when I hit refresh. Then I use the functionality on the main page (add an entry and hit submit) and I get the 500 error. The shows the following:

update "user" set "version" = $1, "num_entries" = $2, "last_entry" = $3 where "id" = $4 and "version" = $5
[2011-Dec-29 12:23:45.416959] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [error] "Wt: error during event handling: Stale object, id = 1, version = 8"
[2011-Dec-29 12:23:45.417509] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [error] "Wt: fatal error: Stale object, id = 1, version = 8"
[2011-Dec-29 12:23:45.418513] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [info] "WebRequest: took 7.645ms"
Warning: Wt::Dbo::Session exiting with 1 dirty objects
[2011-Dec-29 12:23:45.425883] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [info] "Wt: session destroyed (#sessions = 0)"
[2011-Dec-29 12:23:46.804904] 22865 - [info] "Wt: session created (#sessions = 1)"
[2011-Dec-29 12:23:46.805545] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [info] "WEnvironment: UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7"
[2011-Dec-29 12:23:46.805959] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [info] "Wt: signal from dead session, sending reload."
[2011-Dec-29 12:23:46.806912] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [info] "WebRequest: took 2.554ms"
[2011-Dec-29 12:23:46.807236] 22865 [/myapp.wt rkuFVcAZvKpVQ6Nm] [info] "Wt: session destroyed (#sessions = 0)"
read: Connection reset by peer
[Thu Dec 29 12:23:47 2011] [warn] [client 129.25.11.190] mod_fcgid: error reading data, FastCGI server closed connection, referer: http://myapp.mydomain.com/myapp.wt/entries/software
[Thu Dec 29 12:23:47 2011] [error] [client 129.25.11.190] Premature end of script headers: myapp.wt, referer: http://myapp.mydomain.com/myapp.wt/entries/software
[2011-Dec-29 12:23:47.817708] 20544 - [info] "wtfcgi: caught SIGCHLD: pid=22865, stat=0"
[2011-Dec-29 12:23:47.817937] 20544 - [info] "wtfcgi: deleting session: rkuFVcAZvKpVQ6Nm"
[2011-Dec-29 12:23:51.299561] 20544 - [info] "wtfcgi: shutdown (caught SIGTERM)"

RE: Apache fcgi deployment: 404 errors - Added by Sean Lynch over 13 years ago

Also, if I then manually type in the url for the main page http://myapp.mydomain.com/myapp.wt/myapp

I get the error in the browser

Error occurred.

Dbo load(): no active transaction
    (1-5/5)