This is an old revision of the document!


Use Apache HTTP Server with Synchronet

The Apache HTTP Server (httpd) supports dynamic content via external executables called CGI programs.

JSexec

The easiest way to get dynamic Synchronet content (e.g. users, messages, files) served by the Apache HTTP Server is by using JSexec as a CGI program to execute JavaScript (e.g. .js or .ssjs) files that generate dynamic HTML (on stdout).

CGI JavaScript

JavaScript code that generates dynamic CGI content must first send one or more headers, followed by a blank-line, followed by the actual content (e.g. HTML).

Example

As an example, the following generates a very basic one-line header (declaring the content to be plain-text), followed by a blank line, followed by one line of text (the ubiquitous Hello, World!):

print("Content-Type: text/plain");
print();
print("Hello, world!");

:!: If the content is going to contain HTML, then you would want to declare the Content-Type to be text/html instead.

Unix Examples

For example, to execute the exec/nodelist-html.js script to display to a web client a dynamically-generated BBS node list in HTML, create a file named nodelist in your Apache content cgi-bin directory containing the following 2 lines:

#!/bin/sh
exec /sbbs/exec/jsexec -c/sbbs/ctrl nodelist-html.js

:!: Don't forget to make the file executable: chmod a+x nodelist

Now when a web client requests the URL http://yourbbs.com/cgi-bin/nodelist from your Apache HTTP Server, they'll get the dynamic Synchronet node-list in HTML.

Another option is to embed the JavaScript code in the CGI executable file itself. As an example, creating the file cgi-bin/test.cgi containing the following 4 lines:

#!/usr/sbin/jsexec -c/sbbs/ctrl
print("Content-Type: text/plain");
print();
print("Hello, world!");

:!: Don't forget to make the file executable: chmod a+x test.cgi

Now when a web client requests the URL http://yourbbs.com/cgi-bin/test.cgi from your Apache HTTP Server, they'll get the “Hello, world!” message.

See Also

howto/apache.1268900376.txt · Last modified: 2010/03/18 01:19 by digitalman
Back to top
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0