Make a new site
First, it's a good idea to make sure the example site works.
Do this by compiling and running the server with the example configuration.
Now try to visit http://localhost:8080/ in a web browser.
If it works, next step is to either make a new site under the example configuration, or make a new configuration.
This is how to make a new configuration and add a new static site to it:
- Make a new directory under the conf directory. You can call it "default" if you want to make this the configuration that is built by default.
- Enter the newly created directory and make three files (look at the example conf for help):
Add a new directory in the project root, with the name of your site, e.g. "mysite".
In your site directory, add mysite.c (the file compiled by your build.sh). In this file you need to:
- build.sh - This script should build your site and create an executable with the same name as your site in the directory of your site.
- respond.c - This file should contain a function called `respond` that will run directly on the web server (not in your site executable). It needs to send the HTTP response to the socket of the client. This is usually done by executing your site program by calling the `respond_site` function and then returning true (true means that we responded to the request).
- servers.c - Needs to define an array of `struct ChildServer` named `children`. This file tells the supervisor what servers it should start and keep alive.
Add the directory under your site directory where you will put the files to serve. This directory is called "files" in the example site.
- `#define SITE_IS_HTTP 1` if you want your site to work with the HTTP server. It is also possible to make sites that use other interfaces.
- `#include "../src/site.c"`. Must be done below the preprocessor definitions.
- Define the function `site_respond`. All this function needs to do is to write the HTTP response to standard out. For a simple static site, this function can just call `respond_file` where the second argument should be the name of a directory under your site directory where you will store the files you want to serve.
|conf/||Environment and build configurations. Determines what sites are built and executed when running the server. Specified to the build script, e.g. `./build.sh conf=example`.|
|doc/||Server documentation. Available either by opening doc/index.html directly or by running the example site and following the link on the example front page.|
|example/||Example website. Look here to see how to make your own site. This site uses static files, dynamic pages and database.|
|src/||Server source code. Entry points:|
|Source file||Output file||Description|
|src/cinj.c||./cinj||C-injection compiler; code injection into pages.|
|src/dbserver.c||./example/exampledb.so (site specific)||Database server. Included and compiled by each site as library with entry point `server_main`.|
|src/dbspec.c||./dbspec||Database definition language.|
|src/master.c||./server||Supervisor. Run this to run the server.|
|src/site.c||./example/example (site specific)||Entry point for websites. Included and compiled by each site.|
|src/test.c||./test||Automatic tests of server functions.|
|src/webserver.c||./webserver.so||The HTTP web server. Compiled as library with entry point `server_main`.|
There is no licence yet because this software has not yet been published.
This is just a preview version.