Skip to content

Installing Links on a fresh VM

James Cheney edited this page Aug 5, 2024 · 11 revisions

Installing Links on a fresh VM using VirtualBox / Vagrant

0.9.8

Note the following instructions assume OPAM version 2.1.0 or greater. They will not work with the older OPAM 1.x versions.

The following instructions explain how to install Links in a freshly installed Ubuntu 20.04 machine. You can use VirtualBox manually or use Vagrant to automate most of the steps. If you use Vagrant, you can use the Vagrantfile and setup.sh files below: placing them in a new directory and typing "vagrant up" should perform the first three steps automatically. If this doesn't work, though, following the steps manually may help you to understand why.

  1. Set up a fresh Ubuntu/focal64 (as appropriate) virtual machine. One can do this manually using VirtualBox by downloading the appropriate disk images and installing, or more automatically using Vagrant and the Ubuntu standard vm images.

  2. Set up IP forwarding for the VM from an appropriate host port (such as 8081) to Links's default port 8080 within the guest VM. Again, one can do this manually using VirtualBox or by adding an appropriate line of configuration to the Vagrantfile.

  3. Within the VM, execute the following commands:

    $ sudo apt install -y m4 postgresql libpq-dev opam
    $ opam init -a
    $ opam switch create 5.1.1
    $ eval $(opam env)
    $ opam install -y postgresql links links-postgresql
    

Again, if using Vagrant then one can automate this by placing the commands in a script "setup.sh" and configuring the Vagrantfile. (This will take several minutes.)

  1. To test that Links is working correctly, do the following (starting from home directory):
    cd .opam/5.1.1/share/links
    linx --path=examples:examples/games examples/webserver/examples-nodb.links
    

The second command should not return; it starts a Web server running on port 8080 of the VM, which should be mapped to port 8081 of your machine. Stopping this process will kill the server.

  1. To test that the examples are working, visit url:
    http://localhost:8080
    

This should result in a web page with links to a number of example programs, and to their source code. However, only the examples that do not require the database will work; configuring the examples that do use the database requires more work.

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/focal64"

  config.vm.network "forwarded_port", guest: 8080, host: 8081

  config.vm.provision "shell", privileged: false, path: "setup.sh"

end

setup.sh

sudo apt install -y m4 postgresql libpq-dev opam
opam init -a
opam switch create 5.1.1
eval $(opam env)
opam install -y postgresql links links-postgresql