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: 127.0.0.1, 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.
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://127.0.0.1:4000In 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/cgi2scgiIn 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_HOST 127.0.0.1 #SetEnv SCGI_PORT 4000 </Directory>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:
#!/bin/sh exec /usr/local/pack/cgi2scgi/cgi2scgi localhost 4000