User Tools

Site Tools


informatics:flaskapp

Flask app on Debian

This guide lists the steps in order to setup the environment for the hosting of a Flask-based app. I'm assuming the IT professional is starting from scratch and a fresh, clean install of Debian is in place.

1) Install sudo

Debian does not come with the sudo program so it has to be installed with apt install sudo.

2) Allow remote ssh:

In order to allow root account login via ssh, edit the sshd_config file. As root, type:

nano /etc/ssh/sshd_config

Add the following line to the file (at the end of the file, for example):

PermitRootLogin yes

…and restart the service:

service ssh restart

Add newuser (or whatever plain user) to sudoers:

as root, run: usermod -aG sudo newuser

The -aG option tells the system to append the user to the specified group. (The -a option is only used with G.)

Install PostgreSQL

PostgreSQL can be installed with:

apt install postgresql postgresql-contrib

PostgreSQL version: PostgreSQL 13.5

Change to user postgres:

su - postgres

psql

postgres=# create user melvin with encrypted password 'password'; 

create database flask_db;

grant all privileges on database flaskdb to melvin;

createdb postgres

GRANT ALL PRIVILEGES ON DATABASE postgres TO postgres;

Allow remote access to PostgreSQL

Exit and run as root:

nano /etc/postgresql/13/main/postgresql.conf

add:

listen_addresses = '*' # what IP address(es) to listen on;

Next, you also have to edit the pg_hba.conf file to control access at a finer grained level. The file path is, in my case: /etc/postgresql/13/main/pg_hba.conf

PostGIS

sudo apt install postgis postgresql-13-postgis-3

sudo -i -u postgres

Troubleshooting

Sources

informatics/flaskapp.txt · Last modified: 2023/02/02 08:58 by sotosoul