Business, Technology, Tutorial, Ubuntu

HOW TO INSTALL AKAUNTING ON UBUNTU SERVER (MANUAL)

I thought I would install Akaunting the long and hard way rather than the one click install with Digital Ocean – which is probably the smart way to go.

I should say that, sadly, after I got Akaunting setup I could not synchronize directly with my bank in Canada as it seems that it does not support the file formats that I need which are:

Quicken 2006 and higher
Microsoft Money 99 and higher
Makisoft Personal and Makisoft the Accountant
QuickBooks, version 6.0 and higher
Simply Accountant (includes Pro version)
Spreadsheet software (in .csv format for Excel, Quattro Pro Lotus)

It is possible to import transactions and such, so there is probably a labour-intensive way to download your Quickbooks data as .xls, convert to .csv and then import into Akaunting…but sadly I have no time to do it.

I’m going to throw this blog online, though, because I may need it later and someone may want to put it on a server and give it a shot and support it. It’s very awesome. I’m very sad I couldn’t switch to it right away.

Here is a page to take you to the requirements

Big Step 1 – Set up the Digital Ocean Droplet

  1. Make sure you already have a domain purchased and reserved for your needs. This is optional but I will assume you’re doing this for tutorial.
  2. Initiate your server / droplet
    I won’t give detailed instructions here because there is lots of documentation out there. I selected the smallest one (at time of writing it’s $5.00 uSD /month for this)
  3. In your domain registrar, point your domain to your server’s name host. In my case it will be digital ocean’s which I will pull from the ‘networking’ section after adding the domain to Digital Ocean. In my case I already had a test domain setup, so what I did was set up a subdomain called “books.domain.com”. The reason you want to do this right away is because
  4. Set up your SSH keys
    Before you install the droplet, make sure your SSH keys are set up properly because you are going to use them a lot in the terminal. Here is some ssh tutorial. Note that it’s a little hard for me to find SSH stuff in the DO backend so for the records it’s at settings / security and then a tab (I think…). If you already have a DO space and SSH keys setup, you are already ready and can use those keys again.
    5.SSH into your new server
    ssh root@123.123.123.123

Note 1: Normally at this point when I install a server I do the usual sudo apt update and upgrade, but not sure if it’s required.

But… you don’t have a sudo user yet so here you go:

Big Step 2 – Make a sudo (non-root super user) user

Set up a non-root user account on the server. This is to reduce your chances of typing a wrong command and killing all your hard work and data.

This is a nice detailed tutorial on this if you’d like here.

Otherwise, this summaries it:

  • Log into the server as root: ssh root@123.123.123.123
  • Make sysadmin user: adduser sysadmin and follow the prompts (should be password prompt and then a few questions)
  • Add new user to the sudo list: sudo usermod -aG sudo sysadmin
  • Switch to new sysadmin user: su sysadmin
  • (Optional) Test the new-found powers by running this and then cancelling: sudo dpkg-reconfigure tzdata

Helpful note
If you find you are not getting prompted for the questions after running the adduser command, it might be because you accidentally ran useradd command like me… weird how it works both ways…

Big Step 3 – Install Stuff

Well, after starting a long tutorial I found one here

This blog had a few issues and ways that I think need some tweaks, so I will only add my running commentary:

  1. Install PHP Packages

In his step 2, he uses ‘apt-get’. That’s old school so just apt install or sudo apt install is best. Further he had an extra space before imap package so copy/paste wouldn’t work. So my first buffet code install looks like this:

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

However, after running it and getting all the way to install page it seemed these three didn’t install (the last ones in the list):

php7.4-bcmath
php7.4-zip
php7.4-curl

I wonder if there is a limitation in number of packages you can install at once? In either case you may wish to run this command to make sure these three are installed:

sudo apt install php7.4-bcmath php7.4-zip php7.4-curl

Here is what I had to run at the end because they were missing so go ahead and run these now, based on a nice tutorial i found:

I got an error on php-openssl with
E: Unable to locate package php-OpenSSL

It seems php already has openssl so i’m continuing without it….

  1. Edit PHP file

For changing your PHP.ini settings, don’t forget if you are not root (it’s smarter not to be root) you will need sudo in front so: sudo nano /etc/php/7.4/apache2/php.ini I wasted 15 minutes editting my file to find out I couldn’t save it because I wasn’t sudo, ha.

also, php.ini is a huge file and it would be nice to know where those adjustments are for smoother scanning.

First section is:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

you will find, in this order:
max_execution_time = 300
memory_limit = 256M

Next section is:
;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;

you will find:
post_max_size = 20M

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

upload_max_filesize = 20M

and finally:

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

which has this default entry:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone = 

which is actually commented out so you should both uncomment and, why not update to your actual timezone instead of chicago? you can find your timezone here?

mine looks like this:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/Vancouver

Big Step 4 – Set up and Secure your MYSQL Mariadb

In step 3 he didn’t secure his mysql… one should do this so add this section:

  1. Create a database name and save it to your password manager. I’m going to use ‘akaunting_db’ for this. You can call it what you’d like.
  2. Create a database user name and a password for this username and do the same in the password manager.
  3. Run this to increase security of database installations:
    sudo mysql_secure_installation
    Follow the prompts with very likely these answers: Enter, Y, password, repeat password, Y, Y, Y, Y

Big Step 5 – Create your Database in Mariadb

Assuming you did the steps above in step 4, you should now be able to log into your database area with your new password you created. I don’t know if you HAVE to use CAPS for the maria commands, but I do just for visual aid, which is probably why we see this around town…

  1. Log into mariadb: sudo mysql -u root -p
  2. Create your database with the database name you saved to your password manager above: CREATE DATABASE akaunting_db;
  3. Create the user and password for the database replacing username and password in the following code with yours between the apostrophes: CREATE USER 'username_here'@'localhost' IDENTIFIED BY 'new_password_here';
  4. Do whatever this does, lol: GRANT ALL ON akaunting_db.* TO 'username_here'@'localhost' IDENTIFIED BY 'same_password_here' WITH GRANT OPTION;
  5. Flush stuff: FLUSH PRIVILEGES;
  6. Exit stuff: EXIT;

Big Step 6 – Folders and Permissions

Here is bullet list commands of this person’s blog which worked well. I did this stuff in my /tmp directory so feel free to do the same:

  • Download files: curl -O -J -L https://akaunting.com/download.php?version=latest
  • Make a directory to hold the filessudo mkdir -p /var/www/html/akaunting
  • Get unzip packages
    The blogger didn’t mention this but before you can unzip you need to:
    sudo apt install unzip

then you can (with sudo):

  • Unzip the files into the newly-created directory: sudo unzip Akaunting_*.zip -d /var/www/html/akaunting/

(you’ll see a lot of ‘inflating’ going on…)

then you can:

  • create correct ownership of directory: sudo chown -R www-data:www-data /var/www/html/akaunting/
  • Create correct file permissions: sudo chmod -R 755 /var/www/html/akaunting/

Big Step 7 – Some Apache stuff

Note ‘ServerAlias’ was missing from his config. you might want to add like my example below:

  • Create and open the Akaunting.conf file for Apache: sudo nano /etc/apache2/sites-available/akaunting.conf
  • Paste this in:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/akaunting
ServerName example.com
ServerAlias www.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>

The rest of the blog from thereon in was good but just use ‘sudo’ if he doesn’t and you are not root.

rest was good for apache stuff just add ‘sudo’

Now, it’s time to Let’s encrypt things.

Install LetsEncrypt

  • Disable the default Apache thing: sudo a2dissite 000-default
  • Install certbot:

sudo apt install software-properties-common
sudo apt-add-repository universe
sudo apt update
sudo apt install certbot python3-certbot-apache

  • Enable the firewall: sudo ufw enable
  • MISSION CRITICAL Right here and right now, be sure you allow the ssh rule in the firewall rules, otherwise, you’ll get locked out of your server like I did. Thankfully with DO if you do get locked out you can go in through their virtual console, but still…So, simply run this line of code to open up SSH in the firewall: sudo ufw allow ssh
  • Let https traffic through so that Letsencrypt can do its thing: sudo ufw allow 'Apache Full'
  • Check the firewall status which should show active, as well as show BOTH 22/tcp and Apache Full enabled for both ipv4 and ipv6. Don’t continue until these are both present: sudo ufw status
  • Run the certbot: sudo certbot --apache

Rest of the steps are as per any other LetsEncrypt install.
I’ve done other more detailed explanations on LetsEncrypt but this should get you going.

Go to your install page

Go to your books.domain.com site where you installed Akaunting and then go through the steps outlined in the blog above. Should be pretty straight forward

Concluding Comments

My only concluding comments are that I’m so sad I can’t actually get rid of Quickbooks online and move to Akaunting… I hope I will see this connect sooner than later 🙂

Hope some or all of this helps one or more of you.

Tagged , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *