Installing GeneWeb 7 as webserver on Raspberry Pi OS

From GeneWeb
Revision as of 16:12, 1 December 2021 by A2 (talk | contribs) (→‎Compiling GeneWeb 7: href link to used iso ; use ocaml 4.11.1 instead of creating new 4.12.1 switch (faster) ; comment opam install failure (seems it's no more failing in v2.0.8) ; comment uunf failure cause)
Jump to navigation Jump to search

This page explains how to run GeneWeb 7 as a CGI service on a home hosted web server running on a Raspberry Pi. Finding a Linux web hosting provider that allows the flexibility needed to run GeneWeb 7 as CGI is neither easy nor cost effective. A Raspberry Pi connected to your home internet connection is a viable alternative, in both flexibility and cost.

This tutorial assumes that you have successfully connected your Raspberry Pi to your home network so that it can be accessed from the internet, i.e. the outside world. This is done by a process called modem port forwarding. Specific instructions on how to do this vary according to the brand and model of your router. Do a search online - surely someone has done it before.

Throughout this article, the IP address referred as, the GED file “jones.ged” and the site domain name “” are meant to be examples and should be replaced as appropriate. See also the disclaimer at the bottom of this page.

Preparing the Raspberry Pi

Download an ISO file of Raspberry Pi OS Lite. On a Mac, use balenaEtcher to format and flash the ISO image directly from the zip file on to a micro SD card. On Windows, use Rufus. For headless installation, copy also the “wpa_supplicant.conf” and “ssh” files to the micro SD card (see for further information).

Start the Raspberry Pi and secure the installation by changing the password for the user 'pi' and create a new password for root. Update system with sudo apt-get update and sudo apt-get upgrade.

Compiling GeneWeb 7

(This has been tested starting with 2021-10-30-raspios-bullseye-armhf-lite.iso in December 2021 on a Rasbperry Pi 3A+.)

Before compiling Geneweb we need to download and install Opam, OCaml, Camlp5 and a few other dependencies.

Install the following packages missing in Rasbperry Pi OS Lite:

sudo apt-get install opam git m4 bubblewrap libgmp-dev libcurl4-gnutls-dev libipc-system-simple-perl libstring-shellquote-perl

Initialise Opam and install Ocaml switch:

opam init
eval $(opam env)

Install Opam packages required to compile GeneWeb:

opam install calendars camlp5 cppo dune jingoo markup ppx_blob ppx_deriving ppx_import stdlib-shims syslog unidecode.0.2.0 uucp uutf uunf

If uunf build fails, increase the 100MB default swap size of Raspberry Pi OS by editing the CONF_SWAPSIZE=500 value in /etc/dphys-swapfile. Restart it with /etc/init.d/dphys-swapfile restart.

Some dependencies, such as camlp5 take some time to build. Now that all Opam packages are installed, download and compile GeneWeb from its git source:

git clone
cd geneweb
ocaml ./ --sosa-legacy --gwdb-legacy --release
make clean distrib

Once finished, GeneWeb compiled version can be find in the directory distribution sub-directory.

Setting up GeneWeb 7

Next we need to place the compiled GeneWeb directory on a location from where it can be accessed by Apache. Create the directory /home/GW.

sudo mkdir /home/GW

Move the directory with the compiled GeneWeb files to the new directory /home/GW, rename it as GeneWeb7 and change ownership of the directory.

sudo mv ./geneweb/distribution /home/GW
sudo mv /home/GW/distribution /home/GW/GeneWeb7
sudo chown pi:www-data /home/GW/GeneWeb7

Create two new directories inside the directory /home/GW, one for imported GED files and GeneWeb databases, another for GeneWeb log files:

cd /home/GW
sudo mkdir bases7
sudo mkdir logs

Changes directory permissions to 775.

sudo chmod 775 bases7
sudo chmod 775 logs

Change directory ownership to pi and www-data.

sudo chown -R pi:www-data bases7
sudo chown -R pi:www-data logs

Installing Apache

To run the Raspberry Pi as a web server we need to install Apache (and any dependencies required by Apache).

sudo apt-get install apache2

Change ownership and permissions of the HTML directory created by Apache.

sudo chown -R pi:www-data /var/www/html
sudo chmod -R 770 /var/www/html

Test the "Apache Debian Default Page" on the IP address for your Raspberry Pi (ex: After testing, for security reasons, delete the file index.html from the directory /var/www/html.

Setting up CGI

CGI scripts are placed in the directory /usr/lib/cgi-bin. To test CGI, place a test command file in this directory.

cd /usr/lib/cgi-bin
sudo nano

In the nano editor, copy and paste the following text.

echo 'Content-type: text/html'
echo '<!DOCTYPE html>'
echo '<html xmlns="">'
echo '<body>'
echo 'This is a test for CGI commands'
echo '</body>'
echo '</html>'

Ctrl+X to save the file. Make the script executable.

sudo chmod +x /usr/lib/cgi-bin/

Before we run this test CGI script, we need to enable CGI scripts.

sudo a2enmod cgi
sudo service apache2 restart

On a browser window, type the following (replace with the IP address for your Raspberry Pi):

The browser should display:

This is a test for CGI commands

Now, let’s place a CGI script to run GeneWeb.

sudo nano

Copy the following text.

OPT="-cgi -hd $BIN_DIR -bd $BASES -allowed_tags $BASES/tags.txt -add_lexicon $BIN_DIR/lang/lexicon.txt"
$BIN_DIR/gwd  $OPT -log $LOGS_DIR/gwdl.log 2>$LOGS_DIR/gwd.log

Press Ctrl+X to save. Make the file executable.

sudo chmod +x

Next, we need to place a symbolic link in the HTML directory /var/www/html to a particular directory holding some GeneWeb resources.

cd /var/www/html
ln -s /home/GW/GeneWeb7/gw/etc gw-etc

Uploading a GED file

(Note that you can also import a GeneWeb .gw file.)

Open a separate terminal window and issue the following command (adjusted to your local server environment):

scp /Users/your_home_folder/GED/jones.ged pi@

Upload a .gwd file corresponding to your GED file.

scp /Users/your_home_folder/GED/jones.gwf pi@

For each GED file uploaded, there must be a corresponding .gwf file. If you upload a GED file called “jones.ged”, upload a “jones.gwf” text file.

"Screenshot of a user terminal showing the content of GeneWeb “bases” directory"

A .gwf should contain the following text.


Go back to the Terminal window where you are connected to the Raspberry Pi, and issue the commands:

cd /home/GW/bases7
sudo /home/GW/GeneWeb7/gw/ged2gwb -f /home/GW/bases7/jones.ged -o jones
sudo chown www-data: -R .

GeneWeb will process the GED file uploaded. After importing/processing the GED file, to ensure that GeneWeb 7 works correctly, keep the names of the GeneWeb database and the .gwf file, identical (example: jones.gwb and jones.gwf). If necessary, rename files manually.

Viewing the GeneWeb 7 site

On your browser type a URL with following syntax:

Setting up a domain name

If you wish to share your database online, you will need a domain name to make your Raspberry Pi visible on the outside world.

You can use a free dynamic IP address forwarding service (such as that can provide you with a subdomain, such as, pointing to your Raspberry Pi’s IP address. Historically, these free hosted subdomains have been harvested by trolls and are frequently bombarded with automated hacking attempts - you will soon see the Apache log files showing the intensity of these “attacks”. They could be also banned on social media, such as Facebook, that prohibit sharing of addresses using DNS.

For these reasons, it is advisable to register your own domain. You can register a .com, a .info or even a national domain (.fr or .de, for instance) for a few Euro per year. To register a domain, you will need to use the services of a registrar or an intermediary (such as Whichever one you choose, make sure that they will allow you to set your own DNS servers for the new domain.

Register the domain using the default DNS server information. Once you have completed the domain name registration, we need to set up the virtual host for that domain on the Raspberry Pi. For the purpose of this exercise, we are using the domain “”.

Create the Virtual Host file for the domain. The file name has the domain name followed by a “.conf” extension.

sudo nano /etc/apache2/sites-available/

Type the following text, replacing all instances of “” with your own domain name.

<VirtualHost *:80>

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/mygeneweb.info_error.log
CustomLog ${APACHE_LOG_DIR}/mygeneweb.info_access.log combined


Press Ctrl+X. Now, enable the new virtual host.

sudo a2ensite

Restart Apache.

sudo systemctl restart apache2

Connecting your domain name to your RPi

To have your domain name resolve to your Raspberry Pi hosted GeneWeb site, you need to map the domain name to the IP address of the Raspberry Pi. This is done through a DNS file. For security reasons, we should try to keep this information as obfuscated as possible. As such, we’ll use an intermediary service - Cloudflare - between your domain name registrar and your home network where the Raspberry Pi web server sits.

Go to Cloudflare and create an account. Choose the free plan, valid for one domain. Enter your domain name. Cloudflare will display the minimum information required for the new DNS file for your domain. On the first line starting with “Type A” click on the “points to …” cell and change the IP number displayed with the IP address for your Raspberry Pi. Click continue to save.

"Screenshot of Cloudflare web site for DNS setup"

Clouldflare will now display the names of the name servers where the information for your site resides: and Go to the site where you manage your domain name and change the name server information for your domain with the Cloudflare’s name servers.

On the Clouldflare site confirm that you have changed the name server information. Cloudflare will queue your site for verification. Once it has verified the updated name server information, the site will be active on Cloudflare.

Enabling encryption

As we are using Cloudflare for the name servers and as intermediary between internet users and our home Raspberry Pi web server, the easiest way to encrypt the GeneWeb site, is to encrypt the traffic between the outside world and Cloudflare. The traffic from Cloudflare to our home server (and vice-versa) is unencrypted. Visitors to the GeneWeb site will still see the site marked with a padlock next to the URL, meaning that is encrypted.

To enable this option, log in to Cloudflare, choose your domain, click on the icon “Crypto” and on the first option “SSL”, choose “Flexible” from the dropdown menu. Your site will show as encrypted.

Set GeneWeb as the default when accessing your site

Go to /var/www/html directory and create an index.html file.

cd /var/www/html
sudo nano index.html

Copy the following code, adjusted for your environment:

<meta http-equiv="refresh" content="0; URL='https://your-domain-name/cgi-bin/'" />

Press Ctrl+X to save the file. Make sure that there are no other index.html or index.htm files in the same directory.

Your domain name should now load GeneWeb 7 automatically!

"Screenshot of the welcome page of GeneWeb version 7"

Disclaimer: Like anything involving computers, software, programming languages and the internet, the above procedure has been tested and deemed accurate at the time of writing (written in July 2019, updated on January 22, 2021, tested on a Raspberry Pi 4 with 4Gb RAM). It is meant to serve as a guide and it may need to be adjusted in the future to take into account any changes to the software or services offered by the third parties referred.

See also

  • Ocaml build GeneWeb on other platforms.
  • https setup a more secure GeneWeb server.
  • Docker install GeneWeb with Docker.