How to Install Invoice Ninja on Arch Linux

Invoice Ninja is an online invoicing and payment solution for freelancers and businesses. In this tutorial, we will go through the steps to install Invoice Ninja on Arch Linux.

Prerequisites

Step 1: Install Required Dependencies

Before we install Invoice Ninja, we need to install some required tools and dependencies. Run the following command to install them:

sudo pacman -S git php php-gd php-intl php-mbstring php-pdo php-xml

Step 2: Clone Invoice Ninja Repository

Now, we will clone the Invoice Ninja repository using Git. Run the following commands to clone the repository and move into the cloned directory:

git clone https://github.com/invoiceninja/invoiceninja.git
cd invoiceninja

Step 3: Configure Apache or Nginx

Invoice Ninja needs a web server to run. We can use either Apache or Nginx. In this tutorial, we will use Apache.

Configure Apache

First, install Apache using the following command:

sudo pacman -S apache

Next, enable and start the Apache service:

sudo systemctl enable --now httpd

Configure Nginx

If you prefer to use Nginx, first install it using the following command:

sudo pacman -S nginx

Next, start the Nginx service:

sudo systemctl enable --now nginx

Step 4: Configure PHP

Now, we need to configure PHP by editing the /etc/php/php.ini file. Open the file using your preferred text editor and find the following lines:

; extension=curl
; extension=pdo_mysql

Remove the semicolon (;) from the beginning of these two lines to enable the extensions.

extension=curl
extension=pdo_mysql

Save and close the file.

Step 5: Configure the Database

Invoice Ninja needs a database to store the data. In this tutorial, we will use MariaDB.

First, install MariaDB using the following command:

sudo pacman -S mariadb

Next, start the MariaDB service:

sudo systemctl enable --now mariadb

Now, we need to create a new database and user for Invoice Ninja. Run the following commands to create a new database named ninja and a new user named ninjauser with a password:

mysql -u root -p
CREATE DATABASE ninja;
CREATE USER 'ninjauser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON ninja.* TO 'ninjauser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace password with a strong password of your choice.

Step 6: Install Invoice Ninja

Now, we are ready to install Invoice Ninja. Run the following command to install it:

composer install --no-dev --optimize-autoloader

This will install all the required dependencies for Invoice Ninja.

Next, copy the .env.example file to .env:

cp .env.example .env

Edit the .env file using your preferred text editor and set the following parameters:

APP_NAME="Invoice Ninja"
APP_ENV=production
APP_URL=http://localhost

DB_HOST=localhost
DB_DATABASE=ninja
DB_USERNAME=ninjauser
DB_PASSWORD=password

MAIL_ENCRYPTION=null

Make sure to replace password with the password you set for the ninjauser user earlier.

Step 7: Generate the Application Key

Invoiceninja needs an application key to run. Run the following command to generate the key:

php artisan key:generate --force

Step 8: Run the Migration

Now, we need to run the migration to create the necessary tables in the database:

php artisan migrate --seed

This will create the tables and seed the database with some basic data.

Step 9: Configure Permissions

We need to configure the file permissions for Invoice Ninja. Run the following commands to set the correct permissions:

sudo chown -R http:http storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache

Step 10: Configure the Virtual Host

Now, we need to configure a virtual host for Invoice Ninja in Apache. Create a new virtual host file using your preferred text editor:

sudo nano /etc/httpd/conf/extra/invoiceninja.conf

Add the following lines to the file:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /path/to/invoiceninja/public
    <Directory /path/to/invoiceninja/public>
        AllowOverride All
    </Directory>
</VirtualHost>

Make sure to replace example.com with your domain name, and /path/to/invoiceninja/public with the absolute path to the public directory inside the Invoice Ninja directory.

Save and close the file.

If you're using Nginx, configure the server block as follows:

server {
    listen 80;
    server_name example.com;

    root /path/to/invoiceninja/public;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Make sure to replace example.com with your domain name, and /path/to/invoiceninja/public with the absolute path to the public directory inside the Invoice Ninja directory.

Save and close the file.

Step 11: Restart the Web Server

Finally, restart the Apache or Nginx server to apply the changes:

sudo systemctl restart httpd

or

sudo systemctl restart nginx

Step 12: Access the Invoice Ninja Web Interface

Now, open your web browser and navigate to your Invoice Ninja domain name. You should see the Invoice Ninja login page.

Log in with the default credentials:

That's it! You have successfully installed Invoice Ninja on Arch Linux. You can now create invoices and manage your payments using Invoice Ninja.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!