Install System Dependencies

Last Updated: September 2022

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

CentOS:

sudo yum 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

CentOS:

sudo yum 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
    

    CentOS:

    sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
    sudo dnf -qy module disable postgresql
    sudo dnf -y install postgresql12 postgresql12-server
    

    Initialize the database:

    # Initialize the database
    sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
    

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

    sudo systemctl start postgresql-12
    sudo systemctl enable postgresql-12
    

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 CentOS and Ubuntu. Ubuntu packages are usually installed with a reasonable default configurtaion and already enabled and running, whereas CentOS only installs the binaries and leaves the configurtaion and enabling up to you.

  1. Verify that PostgreSQL is Running:

    Ubuntu:

    sudo systemctl status postgresql
    

    CentOS:

    sudo systemctl status postgresql-12
    

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 PostgreSQL 12 on CentOS 7 / CentOS 8.

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 CentOS it is also necessary to enable password authentication for local connections. This is done in the pg_hba.conf file as follows:

    CentOS:

    sudo vim /var/lib/pgsql/12/data/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
    

    To:

    # "local" is for Unix domain socket connections only
    local   all             all                                     md5
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            md5
    # IPv6 local connections:
    host    all             all             ::1/128                 md5
    

    Then restart PostgreSQL:

    sudo systemctl restart postgresql-12
    
  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
    

    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-12-postgis-3

CentOS:

sudo yum install -y epel-release
sudo dnf config-manager --set-enabled PowerTools
sudo yum install -y postgis30_12

NGINX

NGINX (pronounced "N-gin-X") is a free and open-source HTTP server and reverse proxy. It is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. NGINX is used in combination with Daphne as an HTTP server to host Tethys Portal in production.

Install NGINX as follows:

Ubuntu:

sudo apt install -y nginx

Disable and stop NGINX because it will be managed with Supervisor

sudo systemctl stop nginx  # Will manage w/ supervisor
sudo systemctl disable nginx  # Will manage w/ supervisor

CentOS:

sudo yum install -y nginx

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

CentOS:

sudo yum install -y epel-release
sudo yum update
sudo yum 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

Note

These instructions are based on Installing Supervisor, Install EPEL, and Installing Supervisor on CentOS 7.

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

CentOS:

sudo yum 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