Enter name of role to add: directus
Shall the new role be a superuser? (y/n) y
Luego le establecemos una contraseña
sudo -i -u postgres
psql
\password directus
Resultado
Enter new password for user "directus": $Ska198
Enter it again:$Ska198
Crear Base de Datos
Para crear la base de datos ejecutamos
# Ingresamos
sudo -i -u postgres
# Creamos la base de datos
createdb directus
# O sin ingresar
sudo -u postgres createdb directus
Crear usuario Linux para ingresar a la BD
Creamos usuario de sistema que se llame igual al rol y BD
# Salimos de postgres
exit
# Creamos el usuario
sudo adduser directus
RESULTADO
Añadiendo el usuario `directus' ...
Añadiendo el nuevo grupo `directus' (1001) ...
Añadiendo el nuevo usuario `directus' (1001) con grupo `directus' ...
Nueva contraseña: $Ska198
Vuelva a escribir la nueva contraseña: $Ska198
passwd: contraseña actualizada correctamente
Cambiando la información de usuario para directus
Introduzca el nuevo valor, o presione INTRO para el predeterminado
Nombre completo []: Directus
Número de habitación []:
Teléfono del trabajo []:
Teléfono de casa []:
Otro []:
¿Es correcta la información? [S/n]
Ahora podemos ingresar directamente con el usuario
sudo -u directus psql
RESULTADO
psql (14.11 (Ubuntu 14.11-0ubuntu0.22.04.1))
Type "help" for help.
directus=#
Si desea conectarse a otra BD
psql -d nombre_base_datos
Si desea ver la información de la conexión
\conninfo
Resultado
You are connected to database "directus" as user "directus" via socket in "/var/run/postgresql" at port "5432".
Instalar pgAdmin
Para instalar la aplicación de administración de postgresql
ejecutamos la instlación de solo la versión desktop
# Obtener llave
curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
# configurar repositorio
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
# Install for both desktop and web modes:
sudo apt install pgadmin4
# Install for desktop mode only:
sudo apt install pgadmin4-desktop
# Install for web mode only:
sudo apt install pgadmin4-web
# Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
RESULTADO
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:
/home/tavo/.rustup
This can be modified with the RUSTUP_HOME environment variable.
The Cargo home directory is located at:
/home/tavo/.cargo
This can be modified with the CARGO_HOME environment variable.
The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:
/home/tavo/.cargo/bin
This path will then be added to your PATH environment variable by
modifying the profile files located at:
/home/tavo/.profile
/home/tavo/.bashrc
You can uninstall at any time with rustup self uninstall and
these changes will be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable (default)
profile: default
modify PATH variable: yes
1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>1
# Instalamos dependencias
sudo apt-get install python2 g++ build-essential
# Ingresamos al directorio
cd /home/tavo/
# Creamos el directorio
mkdir gym_directus
# ingresamos al directorio
cd gym_directus
# Instalamos isolated-vm
npm install isolated-vm
#Instalamos directus
npm init directus-project@latest gym
Nos pide selecciona la base de datos seleccionamos postgresql
> npx
> cdp gym
? Choose your database client (Use arrow keys)
❯ PostgreSQL / Redshift
CockroachDB (Beta)
MySQL / MariaDB / Aurora
SQLite
Microsoft SQL Server
Oracle Database
Nos pide
? Choose your database client PostgreSQL / Redshift
? Database Host: 127.0.0.1
? Port: 5432
? Database Name: directus
? Database User: directus
? Database Password: $Ska198
? Enable SSL: (y/N) N
Create your first admin user:
? Email gustavo.matamoros@gmail.com
? Password $Ska198
Your project has been created at /home/tavo/directus/gym.
The configuration can be found in /home/tavo/directus/gym/.env
Start Directus by running:
cd /home/tavo/directus/gym
npx directus start
sudo npm install pm2@latest -g
#Actualizar
npm install -g npm@10.8.2
# Dentro del directorio de gym
cd /home/tavo/gym_directus/gym/
# lo mandamos agregar pm2
pm2 start npx --name "directus" -- directus start
# indicamos que arraque con el sistema operativo
pm2 startup systemd
# este comando devuelve un comando que debemos ejecutar
sudo env PATH=$PATH:/home/tavo/.local/share/fnm/node-versions/v18.17.0/installation/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u tavo --hp /home/tavo
# Mandamos a guardar
pm2 save
Forma 2
# Creamos script
nano /home/tavo/start_directus.sh
# Le agregamos
#!/bin/bash
cd /home/tavo/gym_directus/gym
npx directus start
# le damos permisos
chmod +x /home/tavo/start_directus.sh
# Abrimos crontab
crontab -e
# agregamos
@reboot /home/tavo/start_directus.sh
Certificado Letsencrypt
# Ya debemos tener creado los dominios
# directus.sada.services
# api.directus.sada.services
# Dentro de godaddy
# Creamos el virtualhost
nano /etc/apache2/sites-available/directus.sada.services.conf
#Agregamos
<VirtualHost *:80>
ServerName directus.sada.services
ServerAlias www.directus.sada.services
ProxyPass / http://127.0.0.1:8055/
ProxyPassReverse / http://127.0.0.1:8055/
</VirtualHost>
# Habilitamos el sitio
cd /etc/apache2/sites-available/
a2ensite directus.sada.services.conf
# Creamos certificado
sudo certbot --apache
# Resultado
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: sada.services
2: demo.sada.services
3: www.demo.sada.services
4: directus.sada.services
5: www.directus.sada.services
6: gym.sada.services
7: www.gym.sada.services
8: nube.sada.services
9: www.nube.sada.services
10: sae2.sada.services
11: www.sae2.sada.services
12: sigetic.sada.services
13: www.sigetic.sada.services
14: www.sada.services
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 4 5
Requesting a certificate for directus.sada.services and www.directus.sada.services
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/directus.sada.services/fullchain.pem
Key is saved at: /etc/letsencrypt/live/directus.sada.services/privkey.pem
This certificate expires on 2024-10-20.
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 directus.sada.services to /etc/apache2/sites-available/directus.sada.services-le-ssl.conf
Successfully deployed certificate for www.directus.sada.services to /etc/apache2/sites-available/directus.sada.services-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://directus.sada.services and https://www.directus.sada.services
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
# Revisamos que el certobot nueve automaticamente
sudo systemctl status certbot.timer
# Abrimos el archivo
nano /home/tavo/gym_directus/gym/.env
# Agregamos la lineas
DIRECTUS_APP_URL="https://directus.sada.services"
DIRECTUS_API_URL="https://api.directus.sada.services"
# Abrimos el archivo
nano /etc/apache2/sites-available/directus.sada.services-le-ssl.conf
# Y le agregamos
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"