**Note:** _This example is related to "trunk" version of CppCMS that is still not released._ |
|
## Configuration File |
|
Every CppCMS based application should come with a configuration file. |
You can find a configuration file template with full comments in docs folder |
at your CppCMS installation. |
|
We will write a simple file that consists of few lines: |
|
server.api = "fastcgi" |
server.mod = "prefork" |
server.socket = "/tmp/fcgi-hello.socket" |
|
This will define a basic settings for the runtime mode: |
|
1. API that uses CppCMS in communication with web server, in our case "fastcgi". Other options are "scgi" and "cgi". |
2. Worker mode of CppCMS -- prefork -- application forks several processes that |
process queries. Other possible options are single process and thread mode -- "process" and single process multiple threads mode "thread". |
|
We would save it as "config.txt" |
|
## Web Server Configuration |
|
### Lighttpd |
|
Now we need to configure our web server to run our application. We would let lighttpd control processes start up and shout down. |
|
Thus we need add to lighttpd configuration file following: |
|
fastcgi.server = ( "/hello" => |
( "localhost" => |
( |
"check-local" => "disable", |
"max-procs" => 1, |
"bin-path" => "/path/to/hello.fcgi -c /path/to/config.txt", |
"socket" => "/tmp/hello-fastcgi.socket" |
) |
) |
) |
|
Where: |
3. The socket that would use the web server to connect with |
your fastcgi application |
|
- `/hello` is our path to the root of the application on the web site, for example for `www.site.com/hello` it is `/hello`. |
- `/path/to/config.txt` is the location of our configuration file that defines different CppCMS |
parameters we had prepared. For example: `/home/david/projects/hello/config.txt` |
- `/path/to/hello.fcgi` is the path to the location of fastcgi executable we |
compiled before. For example: `/home/david/projects/hello/hello.fcgi` |
|
Make sure, Lighttpd has permissions to run it. |
We would save it as "config.txt" and run [cppcms_run](/wikipp/en/page/man_cppcms_run) utility |
|
### Apache |
cppcms_run hello.fcgi -c config.txt |
|
(TODO) |
If you have lighttpd, nginx or apache2 with mod\_fastcgi installed, they would be configured and started with your application. |
|
## Running |
|
Now restart your web server, open a web browser and go to [http://localhost/hello](http://localhost/hello). You should see "Hello World" |
Now restart your web server, open a web browser and go to [http://localhost:8080/hello.fcgi](http://localhost:8080/hello.fcgi). You should see the traditional "Hello World" |
|