In the foollowing tutorial I will be describing how to set up an InvoiceNinja server on Ubuntu 20.04.

The following commands need to be run as root :

# apt update && apt upgrade -y && apt install apache2 curl git
# systemctl enable apache2.service
# apt install mariadb-server mariadb-client
# systemctl enable mariadb.service
# mysql_secure_installation
# apt install software-properties-common && add-apt-repository ppa:ondrej/php
# apt update
# apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
# nano /etc/php/7.2/apache2/php.ini

Now we have to change some settings in the php.ini file. Change the following lines to :

short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = Europe/Zurich

We have to create a database and user for InvoiceNinja :

# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE invoiceninja;
MariaDB [(none)]> GRANT ALL ON invoiceninja.* TO 'invoiceninjauser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES; 
MariaDB [(none)]> EXIT;

Now we can finally install InvoiceNinja to the server with :

# curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# cd /var/www/ && rm -R ./* && git clone https://github.com/invoiceninja/invoiceninja.git
# cd ./invoiceninja && composer install
# chown -R www-data:www-data /var/www/invoiceninja/
# chmod -R 755 /var/www/invoiceninja/
# rm /etc/apache2/sites-available/*
# nano /etc/apache2/sites-available/invoiceninja.conf

We have to add our apache configuration here. This is an example configuration. You should setup your own configuration by following the apache docs :

<VirtualHost *:80>

    DocumentRoot /var/www/html/invoiceninja/public 
    ServerName example.com 
    ServerAlias www.example.com

    <Directory /var/www/html/invoiceninja/public> 
        Options +FollowSymlinks 
        AllowOverride All 
        Require all granted 
    </Directory> 
    
</VirtualHost>
# a2ensite invoiceninja.conf && a2enmod rewrite
# systemctl restart apache2.service