Coral-Mini Server Specification
Coral-Mini Server has the following specification:
- Server is portable and can be installed on a USB memory stick.
- Server core uses Apache 2.2.21
- Serves by default HTML pages.
- Capability to use .htaccess files for configuration
- Capability to include external pages.
- Uses a file-based database.
- Underlying technology used is hidden.
- The server logs all web requests and errors.
- Includes only the minimum modules to meet specification.
Download the Coral-Mini server from SourceForge Project Page save the file coral_mini_server.exe to any folder of your choice.
Double click on coral_mini_server.exe, starts the extraction process. No need to change the folder destination. Click extract; this creates a new folder MiniServer containing four files and four folders.
- Start_Coral_Mini.exe - Double click to start the server
- Stop_Coral_Mini.exe - Double click to stop server
- tutorial.bat - Displays this tutorial in default browser
- READ_ME.txt - Provides information for changing ports.
- apache2 - Apache sever files and configuration
- control - File to start and stop server
- docs - Tutorial and working scripts from tutorial. Licenses for server.
- www - Root folder. Apache servers files from this folder.
Testing is straight forward.
- Start the server by double clicking on Start_Coral_Mini.exe (automatically configures server paths.)
- Start a web browser.
- Type http://localhost:8081/ into the browser address bar.
- The index page index.html is displayed.
- Stop the server by double clicking on Stop_Coral_Mini.exe
Apache comes with a vast array of modules a full list and description can be found here Apache Docs Modules used in the Coral-mini server are listed below, note the core module is part of the main binary (program) and loaded by default.
Highlighted in bold are separate modules these are loaded using Apache's configuration file httpd.conf.
|core||Core Apache HTTP Server features that are always available included in the binary (program).|
|mpm_winnt.c||WinNT MPM part of the Windows Apache core. A Multi-Processing Module (MPM) it is the default for Windows NT operating systems. Uses a single control process which launches a single child process which in turn creates threads to handle requests. (This is the reason you will see two Apache processes in task manager)|
|authz_host_module||Group authorizations based on host (name or IP address). Required to restrict access to folders etc.|
|mod_dir||Provides for "trailing slash" redirects and serving directory index files. (Optional but nice to have otherwise a user needs to type index.html on entry to a folder or for initial web site access. It prevents this error message: The requested URL / was not found on this server.)|
|mod_log_config||Logging of the requests made to the server. (Not required for server operation however extremely useful to see what the server is doing.)|
|mod_mime||Associates the requested filename's extensions with the file's behavior (handlers and filters) and content (mime-type, language, character set and encoding) Note without this module the file will be served as plain text. DefaultType text/plain|
|mod_rewrite||Provides rewriting of requested URLs on the fly. Allows masking of file extensions for example a request for index.htm results in page index.vbs being run on the server and the result returned as index.htm|
|mod_cgi||Provides an interface for running CGI scripts. Scripts that require running are targeted using the AddHandler directive this directive associates file extensions with CGI scripts.|
On starting Apache it is supplied with the location and name of a configuration file this overrides the default location compiled into the program. Its common practice to name the file httpd.conf and place it in a sub-folder named conf Coral-mini uses this convention.
Coral-Mini Server uses the following configuration file: MiniServer\apache2\conf\httpd.conf
Note: Apache’s example configuration file contains a lot of detailed information I personally find this confusing and prefer to remove this detail.
|httpd.conf located in folder: *\MiniServer\apache2\conf||Comments|
# File name: http.conf
General information a reminder what the configuration is for.
Lists all modules to be loaded.
Note: For some modules the order is important.
Order of priority is from bottom to top; hence if a module is dependent on another it should come first in the list.
These settings are common to the main server. Most settings in this section have defaults however I like to see what I am using hence list them regardless.
Most settings in this section have defaults however again I like to see what I am using hence list them regardless.
Each directory to which Apache has access can be configured with respect to which services and features are allowed and/or disabled in that directory (including its sub-directories).
Apache has access to all folders and files on the drive it is installed on hence the first Directory directive is very restrictive:
Only way to gain access is to target each folder in turn and open it up as required second Directory directive targets folder www this contains your web site.
The AccessFileName directive defines the file name to use for secondary configuration files by convention the name is .htaccess Access to these files is retricted using the Files directive. The regex also prevents .htpasswd files from being viewed by Web clients.
In conjunction with the mime_module the directive TypesConfig is used to specify a file which maps extensions onto MIME types. Note without the module and this file served pages will be in plain text.
This sets up the appropriate log format (what details are logged) and specifies the log file name and location.
Note: debug eats disk space hence warn is a reasonable setting.
Configuring Apache CGI - Overview
The following provides a general overview how to configuring Apache to run CGI scripts. In order to run CGI programs Apache requires configuration directives to permit CGI execution. You can use one of the following methods to permit CGI execution
Note: All three methods require the mod_cgi module to be enabled as shown below:
LoadModule cgi_module modules/mod_cgi.so
Method 1 ScriptAlias
The ScriptAlias directive tells Apache that a particular directory is set aside for CGI programs. Apache now assumes every file in this directory is a CGI program. When a page from this folder is requested Apache will attempt to execute it using the appropriate program.
The ScriptAlias directive looks like:
ScriptAlias /cgi-bin "C:/UniServer/cgi-bin/"
The directive defines a URL prefix (cgi-bin) that is mapped to a particular folder (directory). ScriptAlias informs Apache everything under that URL prefix will be considered a CGI program.
For example, if the URL http://localhost/cgi-bin/test.pl is requested, Apache will attempt to execute the perl file C:/UniServer/cgi-bin/test.pl and return the output.
Similarly, if the URL http://localhost/cgi-bin/test.vbs is requested, Apache will attempt to execute the VBScript file C:/UniServer/cgi-bin/test.vbs and return the output.
Method 2 Folders
On hosted sites for security reasons CGI programs are restricted to ScriptAlias'ed folders. However you can run CGI programs from any folder. As an alternative to ScriptAlias you can use the Options directive, inside your main server configuration file, to specify that CGI execution is permitted in a particular directory.
<Directory "C:/UniServer/www/somedir/"> Options ExecCGI </Directory>
The Options ExecCGI directive informs Apache to permit the execution of CGI files.
Method 3 .htaccess
Using .htaccess files allow you to set configuration directives on a per-directory basis. Apache looks in a folder from which it is serving for this file and applies the directives found. To enable the use of .htaccess files edit the Apache configuration files as follows:
Change or add the AllowOverride directive in a specific folder directive for example www as shown below:
<Directory "C:/UniServer/www/"> Options Indexes Includes AllowOverride All </Directory>
If not already included add the following block of code to prevent .htaccess and .htpasswd files from being viewed by Web clients:
<Files ~ "^\.ht"> Order allow,deny Deny from all Satisfy All </Files>
With the above directives in-place you can now use .htacces files. Create an .htaccess file in the folder where you want to run CGI scripts and add the following line:
Options +ExecCGI Options +FollowSymlinks
Which tells Apache that execution of CGI programs is permitted in this folder.
Note: All Uniform Servers have been pre-configured to allow the use of .htaccess files.
Using either of the above methods Apache will attempt to execute every file as a CGI script this includes files such as css and images. Clearly these are not CGI scripts and would produce errors when executed. To resolve this you need to inform the server what files are genuine CGI scripts using the AddHandler directive.
AddHandler cgi-script .cgi .pl .vbs
The above AddHandler directive informs the server to treat all files with a cgi, pl or vbs extension as CGI programs:
Test folder and .htaccess
Tutorial examples require a test folder and .htaccess file.
- In folder MiniServer\www create a new folder vbs_test this will contain your tutorial scripts.
- Inside this folder create a new .htaccess file with the following content:
|If you have problems creating the .htaccess file copy the one from folder www.
Edit the file: Delete all lines and add the three lines shown on right and save.
AddHandler cgi-script .vbs Options +ExecCGI Options +FollowSymlinks
The above has shown how to configure Apache to run CGI scripts.
Running VBScripts requires an .htaccess file placed in the directory containing the scripts. This file enables script execution and has the following content:
AddHandler cgi-script .vbs Options +ExecCGI Options +FollowSymlinks
Although tutorial examples specifically refer to the Coral-Mini Server they can be run on any Uniform Server that contains Apache 2.2.18 or above. Just create the test folder and add the .htaccess file described above.
Where to next
Next page details how to format a VBScript for running as a CGI script.