Reputation: 922
I'm struggling to set up Apache to work with a Wt app on FastCGI.
I'm using arch linux and Apache 2.4.7. gcc 4.9.0 20140604
The hello world example, which is the simplest example there is, after compilation gives me this error:
[Thu Sep 11 22:46:01.208926 2014] [fastcgi:error] [pid 27628] (101)Network is unreachable: [client 127.0.0.1:52788] FastCGI: failed to connect to server "/xxx/hello/hello.wt": connect() failed, referer: http://local.hello/
[Thu Sep 11 22:46:01.208992 2014] [fastcgi:error] [pid 27628] [client 127.0.0.1:52788] FastCGI: incomplete headers (0 bytes) received from server "/xxx/hello/hello.wt", referer: http://local.hello/
Here's what I do:
Compile with:
$ g++ -o hello.wt hello.cpp -lwtfcgi -lwt
My vhost:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/xxx/hello"
ServerName local.hello
ErrorLog "/var/log/httpd/local.hello-error_log"
CustomLog "/var/log/httpd/local.hello-access_log" common
<Directory /xxx/hello/>
Options All
Require all granted
</Directory>
FastCgiExternalServer /xxx/hello/hello.wt -host 127.0.0.0:9090
</VirtualHost>
and my fastcgi.conf that's being included from httpd.conf:
<IfModule fastcgi_module>
AddHandler fastcgi-script .wt
# FastCgiIpcDir /tmp/fcgi_ipc/ # DOESN'T COMPILE WITH THIS UNCOMMENTED
FastCgiConfig -idle-timeout 100 -maxClassProcesses 1 -initial-env WT_APP_ROOT=/tmp
</IfModule>
If I compile it with:
$ g++ -o hello.wt hello.cpp -lwthttp -lwt
and run it with:
$ ./hello --docroot . --http-address 0.0.0.0 --http-port 9090
everything works fine, so I'm thinking it's something with my apache/fastcgi setup.
Every hint is mostly appreciated.
Upvotes: 2
Views: 3069
Reputation: 12249
I had a similar error but I don't remember exactly what it was, and whether I had different issues, but perhaps your main problem is that you haven't created the /var/run/wt
folder used by Wt to manage sessions when it uses the fastcgi connector.
The thing is that, at least in Ubuntu, /var/run
uses a tmpfs filesystem, which is a filesystem mounted directly in RAM and thus, deleted at each reboot. So, you need to ensure that folder exists and with proper permissions, each time you reboot the server.
Why /var/run/wt
and not another folder? That depends on the folder you have set in your wt_config.xml
file. In Ubuntu 14.04, that file exists under /etc/wt/wt_config.xml
; XML tag <run-directory>
, under the <connector-fcgi>
section. You can change that directive to point to another persistent folder if you want.
What I made however is creating a init
job for creating the /var/run/wt/
folder at startup, creating the file /etc/init/witty.conf
with the following contents (a upstart
script):
#
# This task is run on startup to create the Witty's run folder
# (currently /var/run/wt) with suitable permissions.
description "set witty's run folder (/var/run/wt)"
start on startup
task
exec /usr/local/bin/witty_mkrunfolder
And my witty_mkrunfolder
executable is:
#!/bin/bash
mkdir /var/run/wt
chown -R root:www-data /var/run/wt
chmod -R 770 /var/run/wt
Extra: witty_mkrunfolder
permissions:
$ chown root:root witty_mkrunfolder
$ chmod 750 witty_mkrunfolder
Upvotes: 1