How to Install SolidInvoice on Ubuntu 22.04

SolidInvoice is a free, simple, and elegant invoicing solution based on PHP. It's designed for small businesses to handle their daily billing operations. SolidInvoice provides RESTful API for integration and provides various notification channels such as text messages, emails, or HipChat.

This guide will show you how to install SolidInvoice on an Ubuntu 22.04 server. You'll set up SolidInvoice with the LAMP Stack and secure the installation with Certbot and letsencrypt.

Prerequisites

Before you start, make sure you have:

  • An Ubuntu 22.04 server.
  • A non-root user with sudo privileges.
  • A domain name pointed to a server IP address.

Installing dependencies

SolidInvoice is an open-source invoice application written in PHP and MySQL. To install it, you must install LAMP Stack on your Ubuntu system. In this first step, you will be installing LAMP Stack from the default Ubuntu repository.

Update your Ubuntu package index with the command below.

sudo apt update

Now install LAMP Stack (Linux, Apache, MySQL/MariaDB, and PHP) dependencies using the following command. In this example, you will be using default PHP 8.x for SolidInvoice installation.

sudo apt install apache2 mariadb-server mariadb-client php php-curl php-common php-mbstring php-json php-mysql php-opcache php-bcmath php-intl php-gd php-xml php-soap php-zip php-apcu

Type Y to confirm the installation.

install deps

After installation is finished, run the following command to check the Apache and MariaDB services status to ensure both services are running.

sudo systemctl status apache2
sudo systemctl status mysql

If Apache or MariaDB running, you will see an output active(running).

check apache

Lastly, check the PHP version with the command below. You will see PHP 8.x installed on your Ubuntu system.

php -v

check php

Setting up MariaDB server

After installing the LAMP Stack, you need to set up your MariaDB server installation. First, you will secure the MariaDB server, then create a new database and user that SolidInvoice will use.

To secure the MariaDB server installation, enter the following:

sudo mariadb-secure-installation

In the process, enter Y to confirm the changes to the MariaDB, or N to to reject it. Below are the MariaDB server configurations you will be prompted:

  • The default MariaDB installation comes without a password, press ENTER when prompted for the password.
  • Now input Y to set up the MariaDB root password. Then, type the new password for MariaDB and repeat the password.
  • Input Y to remove the anonymous user from your MariaDB installation.
  • Input Y again when prompted to disable the remote login for the MariaDB root user.
  • Input Y to remove the default database test from your MariaDB.
  • Lastly, input Y to reload table privileges and apply new changes.

Now that you've secured MariaDB, enter the following to log in to MariaDB as the default root user. Input your MariaDB root password when asked.

sudo mariadb -u root -p

Once logged in, run the following queries to create a new database solidinvoicedb, a user solidinvoice, with the password p4ssword. Make sure to change details with your information, these database details will be used by SolidInvoice.

CREATE DATABASE solidinvoicedb;
CREATE USER solidinvoice@localhost IDENTIFIED BY 'p4ssword';
GRANT ALL PRIVILEGES ON solidinvoicedb.* TO solidinvoice@localhost;
FLUSH PRIVILEGES;

create datbase and user

Now run the query below to check privileges for user solidinvoice. Make sure that user solidinvoice can access the database solidinvoicedb.

SHOW GRANTS FOR solidinvoice@localhost;

Lastly, type quit to exit from the MariaDB server.

check db

Setting up PHP

With the MariaDB server secured and configured, you will set up your PHP installation. In this case, you need to modify the default PHP config file php.ini.

Open the default PHP configuration /etc/php/8.1/apache2/php.ini using the nano editor.

sudo nano /etc/php/8.1/apache2/php.ini

Change the default PHP configurations with the following, and make sure to adjust the memory_limit and date.timezone with your server environment.

date.timezone = Europe/Amsterdam
memory_limit=512M
upload_max_filesize=64M
post_max_size=120M
max_execution_time=120

Save the file and exit.

Now restart the Apache service to apply your modification to PHP with the following command.

sudo systemctl restart apache2

Downloading SolidInvoice

So now you have MariaDB and PHP configured, you can now download the SolidInvoice source code and set up the installation with proper permission and ownership.

GO through the /var/www directory and download the SolidInvoice source code using wget. Check the SolidInvoice release page to get the latest version.

cd /var/www/
wget https://github.com/SolidInvoice/SolidInvoice/releases/download/2.2.5/SolidInvoice-2.2.5.zip

Extract the SolidInvoice source code to the solidinvoice directory and change the ownership to the www-data user. So the DocumentRoot or Web-root directory for SolidInvoice installation will be /var/www/solidinvoice.

unzip SolidInvoice-2.2.5.zip -d solidinvoice
sudo chown -R www-data:www-data /var/www/solidinvoice

Now run the command below to make sure the www-data user can write to some of SolidInvoice directories and files.

sudo chmod u+rw /var/www/solidinvoice/app/cache
sudo chmod u+rw /var/www/solidinvoice/app/logs
sudo chmod u+rw /var/www/solidinvoice/var/cache
sudo chmod u+rw /var/www/solidinvoice/var/logs
sudo chmod u+rw /var/www/solidinvoice/web/upload
sudo chmod u+rw /var/www/solidinvoice/app/config/parameters.yml

Setting up Apache virtual host

After you have configured the DocumentRoot directory for SolidInvoice, you need to create a new Apache virtual host that will be used to run the installation. So make sure you have prepared your domain name for SolidInvoice.

First, run the command below to enable the rewrite module in Apache.

sudo a2enmod rewrite

Create a new Apache virtual host configuration /etc/apache2/sites-available/solidinvoice.conf using the nano editor command below.

sudo nano /etc/apache2/sites-available/solidinvoice.conf

Insert the following configuration and make sure to change the ServerName option with your target domain.

<VirtualHost *:80>
ServerName invoice.hwdomain.io
ServerAlias www.invoice.hwdomain.io

DocumentRoot /var/www/solidinvoice/public
<Directory //var/www/solidinvoice/public>
# enable the .htaccess rewrites
AllowOverride All
Order allow,deny
Allow from All
</Directory>

ErrorLog /var/log/apache2/solidinvoice.error.log
CustomLog /var/log/apache2/solidinvoice.access.log combined
</VirtualHost>

Save the file and exit the editor.

Now enter the following command to activate the virtual host file solidinvoice.conf and check your Apache syntax. If you have proper syntax, you will see an output 'Syntax OK'.

sudo a2ensite solidinvoice.conf
sudo apachectl configtest

Lastly, enter the command below to restart Apache and apply the new virtual host file solidinvoice.conf. Once executed, your SolidInvoice should be running.

sudo systemctl restart apache2

setup apache

Securing SolidInvoice with HTTPS

In this example, you will secure SolidInvoice with SSl/TLS certificates via Certbot and letsencrypt. So now you will install Certbot and generate SSL/TLS certificates for your SolidInvoice domain name.

First, install the Certbot and Certbot Apache plugin with the following command. Enter Y to confirm the installation

sudo apt install certbot python3-certbot-apache

Once installation is complete, generate SSL/TLS certificates using the following certbot command. Make sure to change the information of the domain name and email address with your details.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d hwdomain.io

After the process is finished, your SSL/TLS certificates should be available in the /etc/letsencrypt/live/domain.com directory. Also, your SolidInvoice installation should be secured with HTTPS automatically.

Installing SolidInvoice

Open your web browser and visit your domain name such as https://invoice.hwdomain.io/. In the System Requirements Check, make sure everything is OK, then click Next to confirm.

requirements

Select the database driver to MySQL and input details of your MariaDB database and user for SolidInvoice. Once done, click Next again.

db configuration

Now you can see the database schema for SolidInvouice is created, click Next to continue.

db migrations

For the System Settings, select the default locale to English and input details of your admin user, email, and password. Then, click Next again to confirm.

setup admin

Once the installation is complete, you'll see the output 'You have successfully installed SolidInvoice!' and additional instructions to create a cron job.

installation finished

Back to the server terminal and create a new cron job for user www-data with the command below.

sudo crontab -u www-data -e

Paste the crontab script from the page, then save and close the file.

* * * * * php /var/www/solidinvoice/bin/console cron:run -e prod -n

Move back to your web browser and click Log In Now.

login

Now you will be asked to create your company name and default currency. Click Create to confirm.

create orgz

If everything goes well, you should see the SolidInvoice dashboard like the following.

dashboard

Conclusion

Congratulations! You have installed SolidInvoice on Ubuntu 22.04 server. You have the SolidInvoice running with the LAMP Stack (Apache, MySQL/MariaDB, and PHP) on Ubuntu and secured your installation with HTTPS via Letsencrypt. You can now add new components such as the SMTP server to SolidInvoice and use it.

Share this page:

0 Comment(s)