Install System Dependencies

Last Updated: September 2024

This guide describes how to install the necessary system dependencies. You will need sudo or root access on the server to complete these steps.

Tools

The following applications will be used during the installation process, but not necessarily needed by Tethys Portal.

Text Editor

You will need a text editor to modify the configuration files during the installation.

Ubuntu:

sudo apt install -y vim nano

Rocky Linux:

sudo dnf install -y vim nano

wget

Wget is used during the installation to download files needed for the installation, like the install script for Miniconda.

Ubuntu:

sudo apt install -y wget

Rocky Linux:

sudo dnf install -y wget

PostgreSQL

  1. A PostgreSQL database is required for a Tethys Portal installation. For a production installation we recommend that you DO NOT use the database that is installed via conda. Instead install PostgreSQL using the system package manager as follows:

    Ubuntu:

    sudo apt install -y postgresql postgresql-contrib
    

    Rocky Linux:

    sudo dnf install -y postgresql-server glibc-all-langpacks
    

    Initialize the database:

    # Initialize the database
    sudo postgresql-setup --initdb
    

    Start PostgreSQL and enable it so it starts up automatically when the server restarts:

    sudo systemctl start postgresql
    sudo systemctl enable postgresql
    

Note

You may be wondering why you didn't need to initialize the database and start/enable it when installing PostgreSQL on Ubuntu. This has to do with the differing philosophies between Rocky Linux and Ubuntu. Ubuntu packages are usually installed with a default configurtaion and already enabled and running, whereas Rocky Linux only installs the binaries and leaves the configurtaion and enabling up to you.

  1. Verify that PostgreSQL is Running:

    Both:

    sudo systemctl status postgresql
    

Note

Install PostgreSQL using these instructions if you plan on having the database on the same server as your Tethys Portal. If you plan to use a separate server for your database, you may also use these instructions to install PostgreSQL on that server, but do not run these installation commands on the Tethys Portal server. These instructions are based on How To Install and Use PostgreSQL on Ubuntu 20.04 and How To Install and Use PostgreSQL on Rocky Linux 9.

Set postgres Password

  1. The postgres user is the default superuser account that comes installed with PostgreSQL. In this step assign the postgres user a password so that we can initialize it.

    sudo su - postgres
    psql -c "alter user postgres with password '<POSTGRES_PASSWORD>'"
    exit
    

    Note

    Replace <POSTGRES_PASSWORD> with the password you created during the Preparation step.

  2. On Rocky Linux it is also necessary to enable password authentication for local IP connections. This is done in the pg_hba.conf file as follows:

    Rocky Linux:

    sudo vim /var/lib/pgsql/data/pg_hba.conf
    

    pg_hba.conf:

    Change:

    # "local" is for Unix domain socket connections only
    local   all             all                                     peer
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            ident
    # IPv6 local connections:
    host    all             all             ::1/128                 ident
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    local   replication     all                                     peer
    host    replication     all             127.0.0.1/32            ident
    host    replication     all             ::1/128                 ident
    

    To:

    # "local" is for Unix domain socket connections only
    local   all             all                                     peer
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    # IPv6 local connections:
    host    all             all             ::1/128                 md5
    # Allow replication connections from localhost, by a user with the
    # replication privilege.
    local   replication     all                                     peer
    host    replication     all             127.0.0.1/32            md5
    host    replication     all             ::1/128                 md5
    

    Rocky Linux:

    Then restart PostgreSQL:

    sudo systemctl restart postgresql
    
  3. Verify that password authentication is working by opening a connection to the database using the commandline client psql:

    PGPASSWORD=<POSTGRES_PASSWORD> psql -U postgres -h localhost
    

    To quit psql type \q and press Enter.

    Tip

    If authentication isn't working, try rebooting the system and trying again. This can be done by running:

    sudo shutdown -r now
    

    For more information on this topic see: Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

PostGIS Extension (Optional)

PostGIS is an extension for PostgreSQL that adds spatial data types and functions. Using PostGIS you can create databases with columns that can store features and rasters similar to ArcGIS geodatabases. You can also perform common geoprocessing analyses using the spatial database functions.

If the app(s) you plan to install on this server require a spatial persistent store, then install PostGIS as follows:

Ubuntu:

sudo apt install -y postgis postgresql-16-postgis-3

Rocky Linux:

# Install the Postgresql repository
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install EPEL repo RPM:
sudo dnf -y install epel-release

# Enable additional repositories to resolve dependencies
sudo dnf config-manager --enable crb

# Disable default PostgreSQL AppStream repository.
sudo dnf -qy module disable postgresql

# Select the right PostGIS and PostgreSQL versions
sudo yum -y install postgis32_13

# Restart postgresql
systemctl restart postgresql

Apache (Optional)

Apache is a free and open-source cross-platform web server software. If you prefer to use Apache instead of NGINX, you can install it as follows:

Ubuntu:

sudo apt install -y apache2

Disable and stop Apache because it will be managed with Supervisor

sudo systemctl stop apache2
sudo systemctl disable apache2

Rocky Linux:

sudo dnf install -y httpd

Supervisor

Supervisor is a process control system. It allows users to control and monitor many processes on UNIX-like operating systems. Supervisor is used in the Tethys Portal production deployment to control the NGINX and Daphne server processes.

  1. Install Supervisor as follows:

Ubuntu:

# It is not required to start and enable supervisor when installing from apt on Ubuntu
sudo apt update
sudo apt install -y supervisor

Rocky Linux:

# If you haven't already, install the EPEL repository
sudo dnf install -y epel-release
# Install supervisor
sudo dnf install -y supervisor

Start Supervisor and enable it so it starts up automatically when the server restarts:

sudo systemctl start supervisord
sudo systemctl enable supervisord
  1. Use these commands to start, stop, and restart Supervisor:

sudo systemctl start supervisord
sudo systemctl stop supervisord
sudo systemctl restart supervisord

Postfix (Optional)

Postfix is an email server. You should install Postfix if you plan to support the "forgotten password" feature of Tethys Portal.

Install Postfix as follows:

Ubuntu:

sudo apt install -y postfix libsasl2-modules

Rocky Linux:

sudo dnf install -y postfix cyrus-sasl-plain cyrus-sasl-md5

Start Postfix and enable it so it starts up automatically when the server restarts:

sudo systemctl enable postfix
sudo systemctl start postfix