Akaunting is an open-source, web-based accounting platform with invoicing, financial reporting, expense management, and payment tracking, a self-hosted alternative to QuickBooks, WaveApps, or FreshBooks with full control over your accounting data. This guide deploys Akaunting on a LEMP stack, using an external MySQL database server for reliability, and walks through Nginx configuration, TLS, and first-run setup.
Prerequisites: a server with at least 2GB RAM, an external MySQL database (managed or self-hosted), a domain A record, LEMP stack installed, and an Akaunting account API key from akaunting.com/start.
Set Up the Database
Akaunting supports MySQL, PostgreSQL, or SQLite. In production, use an external database server to offload load from the application server.
1. Connect to your MySQL host:
$ mysql -h your-db-host -P 3306 -u dbadmin -p
2. Create the database and user:
mysql> CREATE DATABASE akauntingdb;
mysql> USE akauntingdb;
mysql> CREATE USER 'akauntingadmin'@'localhost' IDENTIFIED BY 'secure-password';
mysql> GRANT ALL PRIVILEGES ON akauntingdb.* TO 'akauntingadmin'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> EXIT
Install Akaunting
1. Install required PHP extensions:
$ sudo apt install php php-fpm php-mysql php-bcmath php-ctype php-curl php-dom php-fileinfo php-intl php-gd php-json php-mbstring php-xml php-zip
2. Verify PHP and Nginx:
$ php -v
$ sudo systemctl status nginx
Note the PHP version reported, you'll need it for the PHP-FPM socket path below.
3. Create the web root and download the latest release:
$ cd /var/www/html/
$ sudo mkdir akaunting.example.com
$ cd akaunting.example.com
$ sudo wget -O akaunting.zip https://akaunting.com/download.php?version=latest
$ sudo unzip akaunting.zip
$ sudo rm akaunting.zip
If unzip is missing: sudo apt install zip unzip.
4. Fix ownership:
$ cd /var/www/html/
$ sudo chown -R www-data:www-data akaunting.example.com
Configure Nginx
1. Create the vhost:
$ cd /etc/nginx/sites-available
$ sudo touch akaunting.conf
$ sudo vim akaunting.conf
2. Add the config (replace akaunting.example.com and the PHP-FPM socket version):
server {
listen 80;
server_name akaunting.example.com;
root /var/www/html/akaunting.example.com;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
error_page 404 /index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.(env|log) {
deny all;
}
location ~ ^/(^app$|bootstrap|config|database|overrides|resources|routes|storage|tests|artisan) {
deny all;
}
location ~ ^/(modules|vendor)\/(.*)\.((?!ico|gif|jpg|jpeg|png|js\b|css|less|sass|font|woff|woff2|eot|ttf|svg|xls|xlsx).)*$ {
deny all;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
3. Enable and test:
$ sudo ln -s /etc/nginx/sites-available/akaunting.conf /etc/nginx/sites-enabled/
$ sudo nginx -t
$ sudo systemctl restart nginx
Secure the Server
1. Firewall:
$ sudo ufw status
$ sudo ufw allow 22 && sudo ufw enable
$ sudo ufw allow 80
$ sudo ufw allow 443
$ sudo ufw reload
2. TLS via Let's Encrypt:
$ sudo apt install python3-certbot-nginx
$ sudo certbot --nginx -d akaunting.example.com -m akaunting@example.com --agree-tos
Verify renewal:
$ sudo certbot renew --dry-run
Access and Configure Akaunting
Visit https://akaunting.example.com:
- Pick a language, click Next.
- Enter your MySQL Hostname, Username, Password, and Database name, then Next to test the connection.
- Enter Company Name and Company Email.
- Set Admin Email and Admin Password, then log in.
- Enter your Akaunting API key (from your account dashboard) or generate one.
- Fill in tax number, financial year start date, company address, country, and logo.
- Pick a default currency and continue.
- Create a sample invoice: add a customer, invoice details and items, save.
- Under Settings → Email Service, configure SMTP so invoices and notifications send by email.
Troubleshooting
Connection timed out — check sudo ufw status for port 443, sudo systemctl status nginx, and sudo cat /var/log/nginx/error.log, then sudo systemctl restart nginx.
Could not connect to the database — log in as the app's DB user (mysql -u akauntingadmin -p) and run SHOW DATABASES; to confirm access; re-grant privileges as admin if the database is missing from the list.
Unable to save admin user/company info — wipe and re-extract the release:
$ sudo rm -r /var/www/html/akaunting.example.com/*
$ sudo wget -O /var/www/html/akaunting.example.com/akaunting.zip https://akaunting.com/download.php?version=latest
$ sudo unzip /var/www/html/akaunting.example.com/akaunting.zip
$ sudo chown -R www-data:www-data /var/www/html/akaunting.example.com/
Then create a fresh database and re-run setup.
502 Bad Gateway — confirm php -v matches the fastcgi_pass socket path in your vhost (/var/run/php/phpX.Y-fpm.sock); update and reload Nginx if they've drifted.
Missing API key — grab it from your Akaunting account dashboard and paste it into the app to unlock full features.
Next Steps
Akaunting is live with an external database, TLS, and a sample invoice. From here:
- Enable multiple company profiles with an upgraded API key
- Integrate SMTP for automated invoice delivery
- Explore Akaunting's module ecosystem for payroll, CRM, or POS extensions
For the full guide, visit the original article on Vultr Docs.
Top comments (0)