V5.11.62 Ubuntu 22.04 Setup/Migration (noob edition)

So - back again. Going to recap what was done up until the setup of NGINX.

Assuming you’ve set up and logged into your box/VM/VPS.

cd /var
mkdir www
cd www
mkdir invoiceninja
cd invoiceninja

Next set of commands used were:

apt dist-upgrade -y
apt install software-properties-common
add-apt-repository ppa:ondrej/php
apt update
apt upgrade

Each time you get prompted - just process it and continue. I then found that all of the other dependencies could be installed if you just list and space them. So…instead of this:

apt install php8.2-bcmath
apt install php8.2-gmp
apt install php8.2-gd
apt install php8.2-mbstring
apt install php8.2-xml
apt install php8.2-curl
apt install php8.2-zip
apt install php8.2-gmp
apt install php8.2-mysql
apt install php8.2-fpm
apt install php8.2-imagick
apt install php8.2-soap
apt install php8.2-common
apt install php8.2-intl

I was able to just run this.

sudo apt install php8.2-bcmath php8.2-gmp php8.2-gd php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip php8.2-gmp php8.2-mysql php8.2-fpm php8.2-imagick php8.2-soap php8.2-common php8.2-intl

So I think that did everything. Next up:

apt install git
apt install mariadb-server mariadb-client nginx vim

wget https://github.com/invoiceninja/invoiceninja/releases/download/v5.11.62/invoiceninja.tar

tar -xvf invoiceninja.tar
rm invoiceninja.tar

Next up is the database creation. Back to the template given.

# mysql -u root -p
Enter Password:  ******
MariaDB .. > create database invoicedb;
MariaDB .. > create user 'ninja'@'localhost' identified by 'ninjapass';
MariaDB .. > grant all privileges on invoicedb.* to 'ninja'@'localhost';
MariaDB .. > flush privileges;
MariaDB .. > exit

Bear in mind that the “invoicedb”, user called “ninja” and the password called “ninjapass” should be changed to what you’d like.

Next we’ll copy the .env file and edit it. First with the copy using sudo cp .env.example .env and then we can edit using sudo nano .env.

Focused on the three entries as stated before.

DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=

sudo chown www-data:www-data /var/www/invoiceninja/.env
sudo php8.2 /var/www/invoiceninja/artisan key:generate
sudo php8.2 /var/www/invoiceninja/artisan migrate:fresh --seed

From here we’re on to STEP 3. This time with NGINX.

sudo nano /etc/nginx/conf.d/invoiceninja.conf

Then we edit and put in the URL for your actual site.

server {
    listen   80;
    listen   [::]:80;
    server_name invoice.yourdomain.com;

    root /var/www/invoiceninja/public/;
    index index.php index.html index.htm;
    charset utf-8;
    client_max_body_size 20M;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    if (!-e $request_filename) {
       rewrite ^(.+)$ /index.php?q= last;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log  /var/log/nginx/invoiceninja.access.log;
    error_log   /var/log/nginx/invoiceninja.error.log;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht {
        deny all;
    }

    sendfile off;
}

sudo nginx -t

If successful then proced - otherwise troubleshoot.

sudo systemctl reload nginx

IN should be available at “ninja.yoursite.com/setup” - but all I get is an error.

No change if I reboot. So now I’m at a loss on how to proceed. Funny though - it does have the IN logo in the browser tab

Any help is welcome. Thanks in advance.

EDIT
I’m going to review this guide once more.

And check if I missed something or can do a mix of what’s there and what I did here. I’ll start by attempting what’s posted there first - as best as I can - and then make changes as needed if I run into errors. Will see if I can get it working or not, but still waiting on any assistance.