Back to Blog

Akaunting Installation Guide (while port 80 is in use)

May 8, 2025โ€ข
ubuntuinstallakauntinghard
Akaunting Installation Guide (while port 80 is in use)

Akaunting Installation Guide (while port 80 is in use)

This guide walks you through installing the Akaunting web app on a virtual machine running Ubuntu server with Apache, PHP, and MySQL. This is considering that it may be a fresh install of the OS.

My situation is likely different from many others. I decided to use Kamal to deploy a Next.js app to the main URL (faithbranch.com) on Digital Ocean Droplet. This means that ports 80 and 443 are taken and we have no access to them. This second set of steps is going to put the app at accounting.url.com:8080 (or in my case accounting.faithbranch.com:8080).

DNS Setup

Update your DNS records to add an A record:

  • Type: A
  • Name: accounting
  • Value: your serverโ€™s IP address
  • TTL: default (e.g. 3600)

Wait for it to propagate.

๐Ÿ“‹ Requirements

โœ… System Update

Update and upgrade your package list:

BASH
sudo apt update
sudo apt upgrade

๐ŸŒ Apache Setup

Apache may already be installed, but it's good to verify:

BASH
sudo apt install apache2
sudo a2enmod rewrite

Change the Apache listening port.

BASH
sudo vim /etc/apache2/ports.conf

Change or add the listening port.

APACHECONF
Listen 8080

Create a new Apache configuration file:

BASH
sudo vim /etc/apache2/sites-available/accounting.url.com.conf

Example config:

APACHECONF
<VirtualHost *:8080>
    ServerName accounting.url.com
    DocumentRoot /var/www/akaunting
    
    <Directory /var/www/akaunting>
        AllowOverride All
        Require all granted
    </Directory>
	
    ErrorLog ${APACHE_LOG_DIR}/accounting_error.log
    CustomLog ${APACHE_LOG_DIR}/accounting_access.log combined
</VirtualHost>

Then enable the site and reload Apache:

BASH
sudo mkdir -p /var/www/akaunting
sudo a2ensite accounting.url.com.conf
sudo systemctl reload apache2

๐Ÿ“œ CertBot Install

โš ๏ธ Caution

This will just assign certificates, but will not get you off of using the 8080 port. You can skip this step for now if you are in a situation like mine and have kamal for your main app.

If anyone knows a way to reverse proxy an application from a kamal app please contact me.

Install Certbot if itโ€™s not already installed:

BASH
sudo apt install certbot python3-certbot-apache

๐Ÿ”ง Manual DNS Challenge

Run:

BASH
sudo certbot certonly --manual --preferred-challenges dns -d accounting.url.com

Youโ€™ll get a prompt like this:

BASH
Please deploy a DNS TXT record under the name
_acme-challenge.accounting.url.com with the following value:
	
    abcdefghijklmnop1234567890
	
Before continuing, verify the record is deployed.
๐ŸŒ 3. Create the TXT Record in Your DNS Provider
  • Go to your DNS management panel (where your domain is hosted: GoDaddy, Cloudflare, Namecheap, etc.)
  • Create a TXT record:
    • Name: _acme-challenge.accounting (do not include .url.com if your DNS provider appends it)
    • Type: TXT
    • Value: The string Certbot gave you (e.g., abcdefghijklmnop1234567890)

โš ๏ธ Wait ~1โ€“5 minutes for DNS to propagate.

โœ… 4. Verify and Continue
  • Once added, press Enter in the terminal to continue Certbot.
  • Certbot will verify the record and issue the certificate.

You should see something like:

BASH
Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/accounting.url.com/fullchain.pem
๐Ÿ“ Step 5: Configure Apache to Use the Certificate

Create an SSL VirtualHost (e.g. in /etc/apache2/sites-available/accounting-ssl.conf):

BASH
<VirtualHost *:443>
    ServerName accounting.url.com
    DocumentRoot /var/www/akaunting
	
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/accounting.url.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/accounting.url.com/privkey.pem
	
    <Directory /var/www/akaunting>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Enable required modules and the site:

BASH
sudo a2enmod ssl
sudo a2ensite accounting-ssl.conf
sudo systemctl reload apache2
๐Ÿ” Certificate Renewal (Manual)

DNS challenges canโ€™t be auto-renewed unless you script it or use a DNS plugin with API access. Otherwise, repeat this process every ~90 days.

โœ… Step-by-Step: DNS-01 Challenge Automation with DigitalOcean

๐Ÿ” 1. Create a DigitalOcean API Token

Go to: https://cloud.digitalocean.com/account/api/tokens

  • Click Generate New Token
  • Name it something like certbot
  • Select read & write scopes (needed for DNS)
  • Save the token somewhere safe (youโ€™ll need it in step 3)
๐Ÿงฉ 2. Install Certbot and the DigitalOcean Plugin
BASH
sudo apt install certbot python3-certbot-dns-digitalocean
๐Ÿ“ 3. Create a Config File for the API Token

Create a secure credentials file:

BASH
sudo mkdir -p /etc/letsencrypt/digitalocean
sudo nano /etc/letsencrypt/digitalocean/credentials.ini

Paste in:

INI
dns_digitalocean_token = YOUR_DIGITALOCEAN_API_TOKEN_HERE

Then:

BASH
sudo chmod 600 /etc/letsencrypt/digitalocean/credentials.ini
๐Ÿƒโ€โ™‚๏ธ 4. Run Certbot Using the DNS Plugin
BASH
sudo certbot certonly \
  --dns-digitalocean \
  --dns-digitalocean-credentials /etc/letsencrypt/digitalocean/credentials.ini \
  -d accounting.url.com

sudo systemctl reload apache2

It will automatically create the TXT record, wait, verify, and issue your cert.

This setup will automatically renew the certificate when certbot renew is run (usually by a cron job or systemd timer).

โš™๏ธ PHP Installation

Install PHP and required extensions:

BASH
sudo apt install php-common libapache2-mod-php php-cli
systemctl restart apache2

sudo apt install php-bcmath php-curl php-dom php-intl php-gd php-mbstring php-xml php-zip php-mysql
systemctl restart apache2

Verify the required modules:

BASH
php -m

Ensure the following are listed:

  • BCMath
  • Ctype
  • cURL
  • DOM
  • FileInfo
  • Intl
  • GD
  • JSON
  • Mbstring
  • mysql
  • OpenSSL
  • PDO
  • Tokenizer
  • XML
  • Zip

๐Ÿ›ข๏ธ MySQL Installation

Install and secure MySQL:

BASH
sudo apt install mysql-server
sudo systemctl start mysql
sudo systemctl enable mysql
sudo mysql_secure_installation

Create the database and user:

BASH
sudo mysql -u root -p

In the MySQL shell:

SQL
CREATE DATABASE akaunting;
CREATE USER 'aka'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON akaunting.* TO 'aka'@'localhost';
FLUSH PRIVILEGES;
\q

๐Ÿ“ฆ Akaunting Installation

  1. Download Akaunting
BASH
sudo apt-get install unzip

curl -L "https://akaunting.com/download.php?version=latest" -o akaunting-latest.zip
unzip akaunting-latest.zip -d akaunting

cd akaunting
mv .env.example .env
cd ~
  1. Replace Apache's default web root
BASH
shopt -s dotglob
sudo mv akaunting/* /var/www/akaunting
  1. Setup Laravel key
BASH
cd /var/www/akaunting
php artisan key:generate
  1. Verify all files are present
BASH
vim . # Check for .env and .htaccess
cd ~

systemctl restart apache2

โœ… Final Steps

  1. Set permissions:
BASH
sudo chown -R www-data:www-data /var/www/akaunting
  1. Visit the Akaunting site in your browser by going to http://accounting.url.com:8080 and start the the installation steps.

ยฉ 2024 Faith Branch Software LLC. All rights reserved.