How to Install Akaunting with Apache and Let's Encrypt SSL on Ubuntu 22.04

Akaunting is an open-source and self-hosted accounting software application for small businesses and freelancers. It is built using Laravel, Bootstrap, jQuery, and RESTful API. It is used for creating and managing invoices, quotes, and finances via a web browser. It provides an awesome App Store for users and developers to extend the functionality of Akaunting.

In this tutorial, I will show you how to install Akaunting accounting software with Apache and Let's Encrypt SSL on Ubuntu 22.04.

Prerequisites

  • A server running Ubuntu 22.04.
  • Valid domain name pointed with your server IP.
  • A root password is configured on the server.

Install Apache, MariaDB, and PHP

First, you will need to install Apache, MariaDB, PHP, and other PHP extensions on your server. You can install all of them by running the following command:

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

After installing all the packages, edit the PHP configuration file and change the default settings:

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

Save and close the file then restart the Apache service to apply the configuration changes:

systemctl restart apache2

Configure MariaDB Database

Akaunting uses a MariaDB/MySQL as a database backend. So you will need to create a database and user for Akaunting.

First, log in to the MariaDB with the following command:

mysql

Once logged in, create a database and user for Akaunting with the following command:

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

Next, grant all privileges to the Akaunting database with the following command:

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

Next, flush the privileges and exit from the MariaDB with the following command:

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

Install Akaunting

First, go to the Akaunting official download page and download the latest version using the following command:

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

Once the download is completed, unzip the downloaded file to the Apache web root directory:

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

Next, change the ownership and permission of the Akaunting directory:

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

Once you are finished, you can proceed to the next step.

Configure Apache for Akaunting

Next, you will need to create an Apache virtual host configuration file for Akaunting. You can create it with the following command:

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

Add the following lines:

<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>

Save and close the file then activate the Apache virtual host and rewrite module with the following command:

a2ensite akaunting
a2enmod rewrite

Next, restart the Apache service to apply the changes:

systemctl restart apache2

You can now check the status of the Apache with the following command:

systemctl status apache2

You will get the following output:

? 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...

Secure Akaunting with Let's Encrypt SSL

Next, it is a good idea to secure your website with Let's Encrypt SSL. First, install the Certbot client using the following command:

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

Once installed, run the following command to secure your website with Let's Encrypt SSL:

certbot --apache -d akaunting.example.com

You will be asked to provide your email and accept the term of service as shown below:

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
cancel): [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

Next, select whether or not to redirect HTTP traffic to HTTPS as shown below:

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 cancel): 2

Type 2 and hit Enter to install the Let's Encrypt SSL for your website:

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

Access Akaunting Web Interface

Now, open your web browser and access the Akaunting web interface using the URL http://akaunting.example.com. You will get the following screen:

Choose language

Select your language and click on the Next button. You will get the database configuration screen:

Database settings

Provide your database details and click on the Next button. You will get the Admin user account creation screen:

Company settings

Provide your company name, email, password and click on the Next button. You will get the Akaunting login screen:

Login

Provide your admin username, password and click on the Login button. You will get the following screen:

Company

Click on the Skip button. You will get the Currencies screen:

Currencies

Enable your currencies and click on the Next button. You will get the plugin screen:

Akaunting dashboard

Install your required modules and click on the Next button. You will get the following screen:

Create new invoice

You can now create your first invoice from the above screen.

Conclusion

Congratulations! you have successfully installed Akaunting with Apache and Let's Encrypt SSL on Ubuntu 22.04 server. You can now host Akaunting software in your organization to manage your invoices, quote, and finances from anywhere. Feel free to ask me if you have any questions.

Share this page:

0 Comment(s)