1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
== Requirements ==
- cabal-install
* See quick installation instructions at the bottom of
http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
- GF installed as a Cabal package
$ (cd ../.. && cabal install)
- FastCGI development kit
(MacPorts) $ sudo port install fcgi
(Ubuntu) $ sudo apt-get install libfcgi-dev
- Google Web Toolkit
- Download from http://code.google.com/webtoolkit/
- Unpack somewhere.
- Set $GWT_CLASSPATH to point to the GWT JAR files. For example:
$ export GWT_DIR="/Users/bringert/src/gwt-mac-1.5.3"
$ export GWT_CLASSPATH="$GWT_DIR/gwt-user.jar:$GWT_DIR/gwt-dev-mac.jar"
== Building ==
- Build pgf.fcgi. This will use cabal to install the dependencies (cgi, fastcgi, json, utf8-string).
$ make
- Build small example grammar:
$ make food.pgf
$ cp food.pgf grammar.pgf
== Running (lighttpd) ==
- Install lighttpd
(MacPorts) $ sudo port install lighttpd
(Ubuntu) $ sudo apt-get install lighttpd
- Run pgf.fcgi with lighttpd:
$ make run
== Testing ==
- First test from the command-line, since debugging is harder from the AJAX UI:
$ curl 'http://localhost:41296/pgf/grammar.pgf/translate?input=this+fish&cat=Item&from=FoodEng'
- Non-GWT AJAX UI:
See http://localhost:41296/simple-client.html
- GWT translator:
$ make gwt-translate
Then see http://localhost:41296/translate/
- GWT fridge poetry:
$ make gwt-fridge
Then see http://localhost:41296/fridge/
- GWT morphology:
$ make gwt-morpho
Then see http://localhost:41296/morpho/
The MorphoService.hs module has build-in paths to the grammar that will be loaded.
This have to be fixed by hand
== Running (Apache) ==
Note: This is more complicated, and the instructions may not be up to date.
- Make sure that your web server supports FastCGI. For Apache on OS X,
do this:
$ curl -O http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
$ tar -zxf mod_fastcgi-2.4.6.tar.gz
$ cd mod_fastcgi-2.4.6/
$ apxs -o mod_fastcgi.so -c *.c
$ sudo apxs -i -a -n fastcgi mod_fastcgi.so
- Make sure that your web server knows that gf.fcgi is a FastCGI
program.
- Make sure that you are allowed to run FastCGI programs in the
directory that you use.
- With large grammars, gf.fcgi may take long enough to start that the web server
thinks that the program has died. With Apache, you can fix this by adding
"FastCgiConfig -startDelay 30" to your httpd.conf.
These sections from my Apache config fixes the above two
(some of this may be fixed by the second apxs command above):
(On OS X, this is in /etc/httpd/httpd.conf)
LoadModule fastcgi_module libexec/httpd/mod_fastcgi.so
AddModule mod_fastcgi.c
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
FastCgiConfig -startDelay 30
</IfModule>
(On OS X, this is in /etc/httpd/users/bringert.conf)
<Directory "/Users/bringert/Sites/">
Options Indexes MultiViews FollowSymlinks ExecCGI
AddHandler cgi-script .cgi
AllowOverride None
Order allow,deny
Allow from all
</Directory>
- If you have changed the web server config, you need to restart the web server
(this is also useful to get a clean slate if you end up with dead or resource-hogging
FastCGI processes):
$ sudo apachectl restart
- If Apache complains about a syntax error on the FastCgiIpcDir line, try deleting
any existing /tmp/fcgi_ipc/ directory:
$ sudo rm -rf /tmp/fcgi_ipc/
- Copy or symlink this directory to your web directory.
- First test from the command-line, since debugging is harder from the AJAX UI:
$ curl 'http://localhost/~bringert/gf-server/gf.fcgi/translate?input=this+fish&cat=Item&from=FoodEng'
- Check server logs (e.g. /var/log/httpd/error_log) if it doesn't work.
- Go to SERVER_URL/simple-client.html in your web browser.
|