<!--toc--> |
|
## Introduction |
|
There are many options to connect CppCMS application to web server: |
|
- Select protocol: you can use FastCGI or SCGI protocols, |
you can also run over HTTP protocol behind proxy. |
|
Recommendation: use FastCGI as it has best support |
over various web servers. |
|
- Application start: it can be started by the web server |
and controlled by it or it can run as independent |
service when web server only connects to it. |
|
- Communication method: you can use Unix domain sockets |
or tcp/ip sockets. For local communication unix sockets |
are preferred. |
|
|
## Assumptions |
|
In all our examples we assume: |
|
- Application's executable placed in `/opt/bin/hello` |
- Application's configuration file placed in `/opt/etc/config.js` |
- Application's executable placed in `/opt/app/bin/hello` |
- Application's configuration file placed in `/opt/app/etc/config.js` |
- The document root is `/var/www` |
- Our application's URL (script) is `/hello` |
|
## Apache2 |
|
### Apache2, FastCGI |
|
#### Apache2, FastCGI, Start by Web Server |
|
You need to enable at least two modules: `mod_fastcgi` and `mod_alias` |
|
First we prepare out `mod_fastcgi` configuration file: |
|
|
FastCgiIpcDir /var/lib/apache2/fastcgi |
# Usually it is given in fastcgi.conf by default |
|
FastCgiServer /opt/bin/hello -initial-env CPPCMS_CONFIG=/opt/etc/config.js -socket /tmp/hello-fcgi-socket |
FastCgiServer /opt/app/bin/hello -initial-env CPPCMS_CONFIG=/opt/app/etc/config.js -socket /tmp/hello-fcgi-socket |
# CPPCMS_CONFIG should hold the path to configuration file. |
|
FastCGIConfig -maxProcesses 1 -processSlack 1 |
# This is important - we want apache to use only |
# one process as we have cache and many other |
# goodies handled by outsefs |
|
ScriptAliasMatch ^/hello(.*)$ /opt/bin/hello$1 |
AddHandler fastcgi-script /opt/bin/hello |
ScriptAliasMatch ^/hello(.*)$ /opt/app/bin/hello$1 |
# We map script "/hello" to our application |
|
AddHandler fastcgi-script /opt/app/bin/hello |
|
|
|
|