Overview of Deploying Akaunting on Server¶
Prerequisites¶
- A fresh Ubuntu 22.04 (or newer) instance with a non‑root user that has sudo privileges.
- Public DNS record pointing to the server’s IP (used later for the domain name).
- Network ports 22, 80, and 443 opened on the firewall (the script uses UFW).
- Basic knowledge of terminal commands (
git,sudo,docker,nginx).
The installation will automatically install all required packages, including Docker, PHP‑8.3, MySQL, Nginx, Certbot, and the required PHP extensions.
Installation Flow¶
The deployment is driven by a set of scripts that perform the following steps in order:
- Clone the Akaunting repository into
/opt/akaunting. - Create configuration files for the database (
db.env) and the application runtime (run.env). - Set up directories for Docker data, Certbot storage, and Nginx configuration.
- Start the Docker stack using
docker‑compose up –detach. - Launch Nginx as a reverse proxy to forward HTTP/HTTPS traffic to the internal Docker container.
- Obtain an SSL certificate from Let’s Encrypt using Certbot and configure Nginx for HTTPS.
- Finalize environment variables to reflect the HTTPS URL and restart the Docker container.
The whole process can be executed with a single shell command that runs the main install.sh (or similar) script located in the root of the cloned repository.
Directory Layout¶
/opt/akaunting/
├── .git/ # Git clone
├── docker-compose.yml # Docker stack definition
├── env/
│ ├── db.env # MySQL connection details
│ └── run.env # Application environment variables
├── data/
│ └── certbot/
│ ├── conf/ # Certbot configuration
│ └── www/ # Webroot for ACME challenge
└── logs/ # Docker log files (optional)
The script also creates:
/etc/nginx/sites-available/akaunting– Nginx site configuration (temporary and final)./etc/nginx/sites-enabled/akaunting– Symlink to the enabled site./etc/letsencrypt/live/<domain>/– Let’s Encrypt certificates after successful issuance.
Permissions¶
| File / Directory | Required Owner | Required Mode | Reason |
|---|---|---|---|
/opt/akaunting | root (or the installing user) | 755 | Allows read/execute by all users, write only by owner. |
/opt/akaunting/env/*.env | root | 600 | Protects database passwords. |
/opt/akaunting/data/certbot | root | 700 | Prevents non‑privileged users from modifying certificates. |
/etc/nginx/sites-available/akaunting | root | 644 | Readable by Nginx worker. |
/etc/letsencrypt/live/<domain> | root | 700 | Certbot stores private keys here. |
The installation script runs as root or via sudo. Docker containers run as the www-data user internally, while Nginx runs as the system nginx user.
Database Setup¶
A MySQL server is installed and configured automatically. The db.env file defines:
MYSQL_DATABASE=akaunting
MYSQL_USER=admin
MYSQL_PASSWORD=<root password>
MYSQL_RANDOM_ROOT_PASSWORD=yes
During Docker stack startup, the akaunting-db service creates the database and user according to these values. The application connects to MySQL using the credentials in run.env.
Docker Container Startup¶
The Docker Compose file defines three primary services:
- akaunting-db – MySQL 8.0 instance.
- akaunting-app – PHP‑8.3 FPM serving the Akaunting application.
- akaunting-nginx – (Optional internal Nginx, but not used because external Nginx proxies).
The command to bring the stack up is:
This pulls the latest images, builds the PHP container, and mounts the /opt/akaunting directory into the container. The container listens on localhost:8080, which is proxied by the external Nginx.
Proxy Server (Nginx)¶
Two Nginx configuration templates are used:
nginx.conf.j2– Temporary configuration that forwards HTTP requests tolocalhost:8080and provides a webroot for Certbot challenge.nginx2.conf.j2– Final configuration after SSL is obtained. It redirects all HTTP traffic to HTTPS and forwards HTTPS requests to the internal container.
During installation, the temporary config is used to run Certbot. After certificate issuance, the final config is applied and Nginx is reloaded.
SSL with Certbot¶
Certbot is installed via apt. The script runs:
The certificates are stored automatically at /etc/letsencrypt/live/<domain>/. They are referenced in the final Nginx config.
Launching the Application¶
After the installation completes, the user can access Akaunting at:
The application is running inside the Docker container, behind the Nginx reverse proxy. Nginx handles TLS termination and passes requests to the internal PHP container.
Updating Akaunting¶
- Pull the latest code:
- Restart Docker containers:
- (Optional) Rebuild Docker images if a
Dockerfilechange is detected:
- Verify that the application is running by visiting the URL.
Updates to the Docker images are handled automatically when the docker-compose pull command is executed.
Reinstalling Akaunting¶
If a fresh install is required:
- Remove the old installation:
- Run the installation script again (the same script used originally). It will recreate all directories, download dependencies, and start the stack from scratch.
Reinstallation clears all configuration files and data; use only if a clean state is needed.
Logging and Monitoring¶
- Docker logs can be viewed with:
- Nginx logs are located at
/var/log/nginx/. - Certbot renewal logs are under
/var/log/letsencrypt/.
The script configures automatic renewal of SSL certificates via a cron job created by Certbot during the installation.