Cómo instalar Akaunting con Apache y Let’s Encrypt SSL en Ubuntu 22.04



Akaunting es una aplicación de software de contabilidad de código amplio y autoalojada para pequeñas empresas y autónomos. Está construida con Laravel, Bootstrap, jQuery y API RESTful. Se utiliza para crear y administrar facturas, presupuestos y finanzas a través de un navegador web. Ofrece una impresionante App Store para que usuarios y desarrolladores amplíen la funcionalidad de Akaunting.

En este tutorial, te mostraré cómo instalar el software de contabilidad Akaunting con Apache y Let’s Encrypt SSL en Ubuntu 22.04.

Requisitos previos

  • Un servidor que ejecute Ubuntu 22.04.
  • Un nombre de dominio válido abonado con la IP de tu servidor.
  • Una contraseña de root configurada en el servidor.

Instalar Apache, MariaDB y PHP

En primer ocasión, tendrás que instalar Apache, MariaDB, PHP y otras extensiones de PHP en tu servidor. Puedes instalarlos todos ejecutando el próximo comando:

apt-get install apache2 mariadb-server php libapache2-mod-php php-common php-imap php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-bcmath php-ldap php-zip php-curl unzip curl -y

Luego de instalar todos los paquetes, edita el archivo de configuración de PHP y cambia la configuración por defecto:

nano /etc/php/8.1/apache2/php.ini
Change the following lines:
memory_limit = 256M
upload_max_filesize = 16M
post_max_size = 16M
max_execution_time = 300
date.timezone = UTC

Tutela y cierra el archivo y reinicia el servicio Apache para aplicar los cambios de configuración:

systemctl restart apache2

Configurar la colchoneta de datos MariaDB

Akaunting utiliza MariaDB/MySQL como colchoneta de datos. Así que tendrás que crear una colchoneta de datos y un legatario para Akaunting.

En primer ocasión, inicia sesión en MariaDB con el próximo comando:

mysql

Una vez conectado, crea una colchoneta de datos y un legatario para Akaunting con el próximo comando:

MariaDB [(none)]> CREATE DATABASE akaunting_db;
MariaDB [(none)]> CREATE USER 'akaunting_user'@'localhost' IDENTIFIED BY 'password';

A continuación, concede todos los privilegios a la colchoneta de datos de Akaunting con el próximo comando:

MariaDB [(none)]> GRANT ALL ON akaunting_db.* TO 'akaunting_user'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

A continuación, vacía los privilegios y sal de MariaDB con el próximo comando:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Instalar Akaunting

Primero, ve a la página oficial de descargas de Akaunting y descarga la última traducción con el próximo comando:

wget -O Akaunting.zip https://akaunting.com/download.php?version=latest

Una vez finalizada la descarga, descomprime el archivo descargado en el directorio raíz web de Apache:

mkdir -p /var/www/html/akaunting
unzip Akaunting.zip -d /var/www/html/akaunting

A continuación, cambia la propiedad y el permiso del directorio Akaunting:

chown -R www-data:www-data /var/www/html/akaunting/
chmod -R 755 /var/www/html/akaunting/

Cuando hayas terminado, puedes advenir al próximo paso.

Configurar Apache para Akaunting

A continuación, tendrás que crear un archivo de configuración del host aparente de Apache para Akaunting. Puedes crearlo con el próximo comando:

nano /etc/apache2/sites-available/akaunting.conf

Añade las siguientes líneas:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/akaunting
ServerName akaunting.example.com
DirectoryIndex index.html index.php
<Directory /var/www/html/akaunting/>
Options +FollowSymlinks
AllowOverride All
Require all granted

</Directory>

ErrorLog ${APACHE_LOG_DIR}/akaunting_error.log
CustomLog ${APACHE_LOG_DIR}/akaunting_access.log combined

</VirtualHost>

Tutela y cierra el archivo y, a continuación, activa el host aparente de Apache y el módulo de reescritura con el próximo comando:

a2ensite akaunting
a2enmod rewrite

A continuación, reinicia el servicio Apache para aplicar los cambios:

systemctl restart apache2

Ahora puedes comprobar el estado del Apache con el próximo comando:

systemctl status apache2

Obtendrás la próximo salida:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-11-12 13:45:47 UTC; 10s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 16032 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 16036 (apache2)
      Tasks: 6 (limit: 464122)
     Memory: 14.2M
     CGroup: /system.slice/apache2.service
             ??16036 /usr/sbin/apache2 -k start
             ??16037 /usr/sbin/apache2 -k start
             ??16038 /usr/sbin/apache2 -k start
             ??16039 /usr/sbin/apache2 -k start
             ??16040 /usr/sbin/apache2 -k start
             ??16041 /usr/sbin/apache2 -k start

Nov 12 13:45:47 ubuntu22041 systemd[1]: Starting The Apache HTTP Server...

Asegura Akaunting con Let’s Encrypt SSL

A continuación, es una buena idea estabilizar tu sitio web con Let’s Encrypt SSL. En primer ocasión, instala el cliente Certbot utilizando el próximo comando:

apt-get install certbot python3-certbot-apache -y

Una vez instalado, ejecuta el próximo comando para estabilizar tu sitio web con Let’s Encrypt SSL:

certbot --apache -d akaunting.example.com

Se te pedirá que proporciones tu correo electrónico y aceptes las condiciones del servicio, como se muestra a continuación:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
contrapuerta): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for akaunting.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/akaunting-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/akaunting-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/akaunting-le-ssl.conf

A continuación, selecciona si deseas o no redirigir el tráfico HTTP a HTTPS, como se muestra a continuación:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to contrapuerta): 2

Escribe 2 y pulsa Intro para instalar Let’s Encrypt SSL en tu sitio web:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/akaunting.conf to ssl vhost in /etc/apache2/sites-available/akaunting-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://akaunting.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=akaunting.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/akaunting.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/akaunting.example.com/privkey.pem
   Your cert will expire on 2023-02-12. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - 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

Accede a la Interfaz Web de Akaunting

Ahora, abre tu navegador y accede a la interfaz web de Akaunting utilizando la URL http://akaunting.example.com. Aparecerá la próximo pantalla:

Elige lengua

Selecciona tu idioma y pulsa el clavija Futuro. Aparecerá la pantalla de configuración de la colchoneta de datos:

Configuración de la base de datos

Proporciona los detalles de tu colchoneta de datos y pulsa el clavija Futuro. Aparecerá la pantalla de creación de la cuenta de legatario Admin:

Configuración de la empresa

Proporciona el nombre de tu empresa, correo electrónico, contraseña y pulsa el clavija Futuro. Aparecerá la pantalla de inicio de sesión de Akaunting:

Iniciar sesión

Proporciona tu nombre de legatario admin, contraseña y pulsa el clavija Iniciar sesión. Aparecerá la próximo pantalla:

Empresa

Pulsa el clavija Olvidar. Aparecerá la pantalla Divisas:

Divisas

Habilita tus monedas y pulsa el clavija Futuro. Aparecerá la pantalla de plugins:

Cuadro de mandos Akaunting

Instala los módulos que necesites y pulsa el clavija Futuro. Aparecerá la próximo pantalla:

Crear una nueva factura

Ahora puedes crear tu primera cuenta desde la pantalla inicial.

Conclusión

Enhorabuena! has instalado con éxito Akaunting con Apache y Let’s Encrypt SSL en el servidor Ubuntu 22.04. Ahora puedes encajar el software Akaunting en tu estructura para administrar tus facturas, presupuestos y finanzas desde cualquier ocasión. No dudes en preguntarme si tienes alguna duda.