Selfhosting setup failing

Hello everyone,

I’ve been trying to get the self-host of invoiceninja working for a while now. On my dedicated server I set up a ubuntu 18.04 VM on which I invoiceninja + mysql and php7.3-fpm (nginx as webserver)

However, I run into a number of problems:

  1. Setup page is not displayed correctly, its is very minimalistic (see screenshot).
  2. After the setup page i get the message: "error: app is already configured, backup then delete the .env file to re-run the setup"
  3. After executing step 2 it displays: "Oops, something went wrong"
  4. after a clean 3rd clean install it displays the loging page very minimalistic (unable to login and it
    displays the IP of the vm in the browsers URL after timeout)

output of laravell-error.log

Blockquote [2021-01-06 22:56:37] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:1,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“login”}
[2021-01-06 22:56:37] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:2,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“login”}
[2021-01-06 22:56:37] production.ERROR: Illuminate\Database\QueryException [1698] : /var/www/invoice-ninja/vendor/laravel/framework/src/Illuminate/Database/Connection.php [Line 664] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ (SQL: select count(*) as aggregate from users where users.deleted_at is null) {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:3,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“login”}
[2021-01-06 22:56:42] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:4,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“/”}
[2021-01-06 22:56:42] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:5,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“/”}
[2021-01-06 22:56:42] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:6,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“setup”}
[2021-01-06 22:56:42] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“GET”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:7,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“setup”}
[2021-01-06 23:11:56] production.ERROR: Doctrine\DBAL\Driver\PDOException [1698] : /var/www/invoice-ninja/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php [Line 47] => SQLSTATE[HY000] [1698

] Access denied for user ‘forge’@‘localhost’ {“context”:“PHP”,“user_id”:0,“account_id”:0,“user_name”:“”,“method”:“POST”,“user_agent”:“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66”,“locale”:“en”,“ip”:“192.168.122.1”,“count”:8,“is_console”:“no”,“is_api”:“no”,“db_server”:“mysql”,“url”:“setup”}

i followed this guide and tested with php 7.2 and 7.3

In the past I’ve had this working with the same guide. I dont know if there has been an update that can cause this issue

please assist on this

Hi,

The errors indicate you may have the wrong database credentials in the .env file

Hi Hilel,

thanks for the fast reply. I have checked and adjusted the .env file. The username and password of the database are correct.
i can connect to the database with mysql -u 'username' -p 'database'.

However, this does not explain why the setup and login page is displayed in a very minimalistic way (if they are displayed). Most of the times its gives the mentioned error codes and i have done a reinstall. I even tried with ubuntu 20.04 and php 7.3 but still the same.

Has there been a update on the version of selfhost?

i thought maybe there was a php module missing. but they all seem to be present:

Blockquote
[PHP Modules]
calendar
Core
ctype
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache

in the laraval log its displaying forge@localhost, but this is not my user

Are you using a proxy?

Hi Hilel,

Yes, the VM (wich invoiceninja is installed) sits behind a reverse proxy on the dedicated server(nginx).
There is no SSL installed for now. Http traffic is passed to the vm

Hi Hilel,

thansk for the reply. I tryed with TRUSTED_PROXIES but that didnt help.

config of rev proxy that passes the traffic to the VM:

server {
listen 80;
listen [::]:80;
server_name invoice.example.com
access_log /var/log/nginx/reverse-access.log;
error_log /var/log/nginx/reverse-error.log;

   location / {
                proxy_pass http://192.168.122.107;

}
}

config of the nginx on VM (invoiceninja)

server {
listen 80;
server_name invoice.example.com;

root /var/www/invoice-ninja/public/;
index index.php index.html index.htm;
charset utf-8;

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

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/php7.3-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;
}

}

as you can see both are using http.

logging of the invoiceninja.error.log

2021/01/07 13:29:13 [error] 16189#16189: *2352 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, client: 192.168.122.1, server:" url-of-invoice", request: “GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.0”, upstream: “fastcgi://unix:/run/php/php7.3-fpm.sock:”, host: “192.168.122.107”

Sorry, I don’t have any other solutions to share.

Hi Hilel,

i got it working with http. in case of reverse proxy with nginx you needed to add proxy_set_header Host $host; under location to the nginx proxy config.

Thanks for your input

nvm… getting Whoops, looks like something went wrong. when logging in. login page is being displayed normal. il keep digging

The application is working now with http traffic.
added this to rev proxy config under location.

                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_redirect off;

and it seems like i was missing the php7.3-curl extension aswell. no need for trusted_proxies
thanks for the input.

1 Like

Glad to hear it’s working, thanks for sharing the solutions!

If you see any errors in the app please send the related logs from storage/logs/laravel.log