Setup step works, after that only 404/500 error

Greetings all,

trying to get ninja v5 to run. Version is 5.3.84, running apache2.4 on ubuntu 20.04, ssh-connected to the remote server. Using mysql, ninja is in /var/www/html/invoiceninja (zip download), php version 8.0 on ubuntu and apache2 both. Also running some other servers with the apache, some using nodejs, some php, these work fine. I did the setup with php artisan generate:key and artisan migrate:fresh --seed. All fine so far.

I was able to reach ninja over <server>/invoiceninja/public/setup from my PC (external, not from the ubuntu server itself). Put in the information, tested PDF-generation, connection to database, email and the other fields. All worked, mail reached me, setup completed, .env was updated with the input data as well.

Now the setup is done and I can’t seem to get further. Trying <server>/invoiceninja/public/index.php gets me a 500 error (ReferenceError: Livewire is not defined in the browser). Going to /invoiceninja/publc or /invoiceninja gets me a 404 error (“Back to <server>”, links to <server>/client). On /invoiceninja it just gives me the 404 report, on /invoiceninja/public I get the same but with some stock-photo on top (ReferenceError: Livewire is not defined as well). Going to invoiceninja/public/setup redirects to invoiceninja/public

Any ideas/ways I can debug this further? I’m a bit confused since the setup worked, so the general dependencies seem to work fine, so are the connections/tests on setup.

Thanks in advance


Can you please check that mod_rewrite is enabled.

@david do you have any thoughts?

The module rewrite is enabled, .htaccess looks fine/was not modified:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteRule "^.env" - [F,L]
#  RewriteRule "^storage" - [F,L]
 RewriteRule ^(.well-known)($|/) - [L]

 RewriteRule ^(.*)$ public/$1 [L]

Is that enough to enable mod_rewrite or do I have to make some additional annotations in the default conf of apache?


By the sounds of it, your APP_URL is missing the /public

You’ll either need to move your directory in apache forward from the root folder to /public


add /public to your APP_URL

/public was indeed missing from APP_URL, its now /invoiceninja/public

Though that still does not seem to fix the problem entirely, here again the error when trying to open /invoiceninja/public/index.php

Not sure if the error could be in the invoiceninja/config/livewire.php, looking at an older setup of invoice ninja I had ‘asset_url’ => env(…), in the current file it was just => null. I changed it as below:

And now at least the Livewire Error is gone, though I still get a 500er when going to /public/index.php

Thanks again for the quick & targeted help.

Ok, I have not fixed it, but at least I understand the problem now. I did delete everything and did a new setup (though same apache, since there are other things running on it). Maybe it will help someone reading it later. The problem is not with ninja/the installation or something else, but with the apache2 routing/pathing. Now after the reinstall I can see the problem clearer.

The application correctly finds stuff in public/vendor like cookieconsent, but it does not find livewire etc in ninja/vendor and instead asks the server for those scripts via /vendor/livewire instead of /ninja/vendor/livewire etc. Not sure why the path is correct for the public/vendor scripts but not for the private ones.

And again me. It works now. Why? I can’t tell you. I didn’t do any changes to the apache2 itself. Installed Invoice again, then going to /ninja/public/index.php/ it correctly loaded and now it just works. Must have been some bad configuration/path to the vendor files, in the .env or whatever. No idea why it was not fixed the first few times I reinstalled, but I’m not going to complain.