Instalar Keycloak en Ubuntu 20.04 LTS

En este articulo vamos a describir como se debe de configurar un servidor Keycloak Server 18 en Ubuntu Server 20.04 LTS.

Requisitos

  • Instala Unzip
  • Instala
  • OpenJdk 11.
sudo apt update
sudo apt install openjdk-11-jdk
sudo update-alternatives --config java
sudo update-alternatives --config javac
  • Apache
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl status apache2
  • CertBot
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Please enter the domain name(s) you would like on your certificate (comma and/or
space separated) (Enter 'c' to cancel): dominio.com
Requesting a certificate for dominio.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/dominio.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/dominio.com/privkey.pem
This certificate expires on 2022-08-31.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for dominio.com to /etc/apache2/sites-available/000-default-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://dominio.com
We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sudo certbot renew --dry-run
  • Postegresql 14
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql
sudo -u postgres psql
postgres# \du
postgres# CREATE ROLE keycloak LOGIN PASSWORD 'securePass1';
postgres# GRANT postgres TO keycloak;
postgres# \q
  • Instalación de keycloak
wget https://github.com/keycloak/keycloak/releases/download/18.0.0/keycloak-18.0.0.zip
unzip keycloak-18.0.0.zip
cd keycloak-18.0.0
mkdir certs