Difference between revisions of "raspbian"

From GeneWeb
Jump to: navigation, search
m (Compiling GeneWeb 7: don't install dune 2.0 atm)
m (Compiling GeneWeb 7: add benchmark to test num/zarith/legacy mode a bit (trying a Pi 3 A+!) ; no need to clean because it's first distrib made)
Line 35: Line 35:
Install Opam packages required to compile GeneWeb. This will take some time.
Install Opam packages required to compile GeneWeb. This will take some time.
<pre>opam install camlp5 cppo dune.1.11.4 markup stdlib-shims num unidecode uucp zarith</pre>
<pre>opam install benchmark camlp5 cppo dune.1.11.4 markup stdlib-shims num unidecode uucp zarith</pre>
Now that all Opam packages are installed, download and compile GeneWeb.
Now that all Opam packages are installed, download and compile GeneWeb.
Line 42: Line 42:
cd geneweb
cd geneweb
ocaml ./configure.ml
ocaml ./configure.ml
make clean distrib</pre>
make distrib</pre>
Once finished, you should have a directory called {{d}} <strong>distribution</strong> - this is the compiled GeneWeb!
Once finished, you should have a directory called {{d}} <strong>distribution</strong> - this is the compiled GeneWeb!

Revision as of 04:12, 7 December 2019

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 “mygeneweb.info” 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 Raspian Lite ISO. On a Mac, use balenaEtcher to format and flash the ISO image directly from the zip file on to a micro SD card. 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

Before compiling Geneweb we need to download and install Opam, OCaml and Camlp5.

Install the following Raspian packages (if not installed already).

sudo apt-get install curl make m4 unzip bubblewrap gcc libgmp-dev git build-essential ocaml

Install Opam.

git clone https://github.com/ocaml/opam.git
cd opam
make lib-ext
sudo make install

Initialise Opam.

opam init
eval $(opam env)

Install Opam packages required to compile GeneWeb. This will take some time.

opam install benchmark camlp5 cppo dune.1.11.4 markup stdlib-shims num unidecode uucp zarith

Now that all Opam packages are installed, download and compile GeneWeb.

git clone https://github.com/geneweb/geneweb
cd geneweb
ocaml ./configure.ml
make distrib

Once finished, you should have a directory called directory distribution - this is the compiled GeneWeb!

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 and rename it as GeneWeb7.

sudo mv ./geneweb/distribution /home/GW
sudo mv /home/GW/distribution /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 pi:www-data bases7
sudo chown 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 test-cgi.sh

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

echo 'Content-type: text/html'
echo '<!DOCTYPE html>'
echo '<html xmlns="http://www.w3.org/1999/xhtml">'
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/test-cgi.sh

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 gwd.sh

Copy the following text.

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

Press Ctrl+X Make the file executable.

sudo chmod +x gwd.sh

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.



particles="AF","AV","D","DAL","DE","DEN","DES","DI","DU","OF","UND","VAN","VON","ZU","ZUR","DE LES","DO","DA","DAS","DOS"

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

cd /home/GW/bases7
/home/GW/GeneWeb7/gw/ged2gwb -f /home/GW/bases7/jones.ged -o jones

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 noip.com) that can provide you with a subdomain, such as http://jones.zapto.org, 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 noip.com 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 godaddy.com). 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 “mygeneweb.info”.

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/mygeneweb.info.conf

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

<VirtualHost *:80>

ServerAdmin your.email@address.com
ServerName mygeneweb.info
ServerAlias www.mygeneweb.info
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 mygeneweb.info.conf

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: adrian.ns.cloudflare.com and dean.ns.cloudflare.com. 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/gwd.sh?b=your-database-name'" />

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 December 02, 2019). 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.