Install PostgreSQL database on Ubuntu 22.04 with optimization for production environments.
Set up PostgreSQL database server on Ubuntu 22.04 with optimal configuration for production use.
sudo apt update
sudo apt install postgresql postgresql-contrib -y
Configure PostgreSQL by editing /etc/postgresql/14/main/postgresql.conf:
max_connections = 200
shared_buffers = 256MB
effective_cache_size = 1GB
work_mem = 4MB
sudo -u postgres psql
CREATE DATABASE myapp;
CREATE USER myuser WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE myapp TO myuser;
Tune shared_buffers to 25% of RAM. Use connection pooling (pgBouncer) for high-traffic applications.
Use pg_dump for logical backups or pg_basebackup for physical backups. Consider setting up streaming replication.
Configuration guides for web servers, databases, and system services
View all articles