PACK Qt Server Binding

Setting up the Server

The Qt Server Binding understands the SCGI protocol to talk to a web server as a server side content provider. Alternatively a simple cgi2scgi gateway can be used to bridge the web server's CGI interface to the Qt binding.

The Qt Server

The Qt binding is a separate server with the actual web server acting as a proxy to it.

An instance of the class WServer must be set up to face the web server, the generated instance of WInterface is registered at one or several instances of WServer. WServer can be set up to use a listening TCP or local socket - although the specification for SCGI specifies TCP only. If you use TCP it is recommended to bind to localhost (IPv4:, IPv6: ::1).

It is also recommended to let the Qt program run as a service, one possibility is to use the QtService solution to implement this.

Setup with Apache

Apache is listed here as an example of a setup, the SCGI protocol is also supported by lighttpd and IIS.

For Apache there are two possibilities for setup: using SCGI and CGI. For SCGI you can use mod_proxy_scgi or mod_scgi, this example is for mod_proxy_scgi:

ProxyPass /localpath scgi://
In this case the Qt server has to be set up using a TCP socket, since Apache implements SCGI to the letter.

Using CGI (mod_cgi or mod_cgid) you need to plug a CGi-to-SCGI bridge between Apache and the Qt binding - one such bridge is the C-program in the cgi2scgi directory, it takes environment variables or arguments to configure its target. First it needs to be linked into Apaches paths:

ScriptAlias /packcgi /usr/local/pack/cgi2scgi/cgi2scgi
In this case the script is linked directly to the path /packcgi - another possibility is to link the path that the cgi2scgi binary is in or to use a wrapper script. If the binary is used directly you have to use mod_env to hand over the configuration:
<Directory "/usr/local/pack/cgi2scgi">
  Options ExecCGI
  Order allow,deny
  Allow from all
  SetEnv SCGI_FILE /tmp/scgisocket
  #SetEnv SCGI_PORT 4000
You have the choice of using SCGI_FILE for an AF_UNIX local socket or SCGI_HOST and SCGI_PORT for a TCP socket. If you use a wrapper script you can use arguments instead - one argument for an AF_UNIX socket, two for TCP:
exec /usr/local/pack/cgi2scgi/cgi2scgi localhost 4000

Binding to the Base

Communication Classes