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.

<img alt="install deps" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/11-install-deps.png6618231a72db6.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="195" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="check apache" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/12-test-apache.png6618231abcb6c.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="308" loading="lazy" src="data:image/svg xml,” width=”750″>

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

php -v

<img alt="check php" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/13-check-php.png6618231ad7fca.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="143" loading="lazy" src="data:image/svg xml,” width=”750″>

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;

<img alt="create datbase and user" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/14-create-db-user.png6618231b01750.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="220" loading="lazy" src="data:image/svg xml,” width=”750″>

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.

<img alt="check db" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/15-check-db.png6618231b3118b.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="245" loading="lazy" src="data:image/svg xml,” width=”750″>

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.



ServerName invoice.hwdomain.io

ServerAlias www.invoice.hwdomain.io

DocumentRoot /var/www/solidinvoice/public



# enable the .htaccess rewrites

AllowOverride All

Order allow,deny

Allow from All

ErrorLog /var/log/apache2/solidinvoice.error.log

CustomLog /var/log/apache2/solidinvoice.access.log combined

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

<img alt="setup apache" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/16-setup-vhost.png6618231b6bc21.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="274" loading="lazy" src="data:image/svg xml,” width=”750″>

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.

<img alt="requirements" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/1-start-instakk.png6618231b8a3f0.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="455" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="db configuration" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/2-db-settings.png6618231ba5e0f.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="750" loading="lazy" src="data:image/svg xml,” width=”659″>

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

<img alt="db migrations" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/3-db-migration.png6618231c00b3c.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="278" loading="lazy" src="data:image/svg xml,” width=”750″>

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.

<img alt="setup admin" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/4-setup-admin.png6618231c1de5e.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="478" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="installation finished" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/5-installation-finished.png6618231c5bc1a.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="365" loading="lazy" src="data:image/svg xml,” width=”750″>

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.

<img alt="login" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/6-login.png6618231c76ed4.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="668" loading="lazy" src="data:image/svg xml,” width=”677″>

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

<img alt="create orgz" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/7-create-default-curr.png6618231c9776c.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="409" loading="lazy" src="data:image/svg xml,” width=”750″>

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

<img alt="dashboard" data-ezsrc="https://kirelos.com/wp-content/uploads/2024/04/echo/8-dashboard.png6618231cb36aa.jpg" ezimgfmt="rs rscb10 src ng ngcb9" height="452" loading="lazy" src="data:image/svg xml,” width=”750″>

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.