Installation: 500 Error After setup script

Hi All,

I’m attempting to migrate from version 4, and I have got as far as running the setup script. All tests passed, but after the script runs, i get a persistant 500 server error. Navigating back runs the setup script again.

I’ve tried all the fixes i can find - artisan fresh seed / artisan optimize - at a loss here!

Any ideas?

Ubuntu 20.04 LTS / Apache2 (running directly on http as Ninja V4 is on https) / PHP 7.3

Thanks,

Luke

[2021-05-31 17:02:32] production.INFO: db fails
[2021-05-31 17:02:39] production.INFO: db fails
[2021-05-31 17:03:19] production.INFO: db fails
[2021-05-31 17:10:28] production.INFO: db fails
[2021-05-31 17:12:09] production.INFO: db fails
[2021-05-31 17:14:24] production.ERROR: Too few arguments to function App\Jobs\Account\CreateAccount::__construct(), 1 passed in /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php on lin>
[stacktrace]
#0 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php(69): App\Jobs\Account\CreateAccount->__construct(Array)
#1 /var/www/html/ninjav5/app/Http/Controllers/SetupController.php(166): App\Jobs\Account\CreateAccount::dispatchNow(Array)
#2 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\SetupController->doSetup(Object(App\Http\Requests\Setup\StoreSetupRequest))
#3 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction(‘doSetup’, Array)
#4 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Route.php(254): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\SetupController), 'do>
#5 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Route.php(197): Illuminate\Routing\Route->runController()
#6 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\Routing\Route->run()
#7 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#8 /var/www/html/ninjav5/app/Http/Middleware/RedirectIfAuthenticated.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#9 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\RedirectIfAuthenticated->handle(Object(Illuminate\Http\Request), Object(Closure))
#10 /var/www/html/ninjav5/app/Http/Middleware/QueryLogging.php(40): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\QueryLogging->handle(Object(Illuminate\Http\Request), Object(Closure))
#12 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#17 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#18 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate>
#20 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#21 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#27 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#28 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#29 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#30 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#31 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#32 /var/www/html/ninjav5/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestIpMiddleware.php(55): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Sentry\Laravel\Http\SetRequestIpMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /var/www/html/ninjav5/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestMiddleware.php(52): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Sentry\Laravel\Http\SetRequestMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 /var/www/html/ninjav5/app/Http/Middleware/Cors.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\Http\Middleware\Cors->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /var/www/html/ninjav5/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request)>
#42 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#44 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closu>
#45 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#47 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Reque>
#49 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 /var/www/html/ninjav5/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Tracing/Middleware.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Sentry\Laravel\Tracing\Middleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#52 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#53 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#54 /var/www/html/ninjav5/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

Hi,

Which version of v5 are you using?

cc @david

HI @hillel - thanks for the prompt attention - the release from 9 hours ago! - https://github.com/invoiceninja/invoiceninja/releases/download/v5.1.67-release/invoiceninja.zip

I tried this time last week with the previous release too - and got the same loop, though i didn;t grab the logs I’m afraid.

This looks like a bug, i am tagging a new release now.

With an install over the existing instance, and a composer install, I’m still getting a loop to the setup script, with a 500 error after I’m about to wipe and try a complete fresh install, so i’ll update with results shortly.

Ok, so with a wipe and fresh install, the error persisted - BUT - after performing a DATABASE DROP in maria db and creating anew database to work on, the script ran, and seemed to complete.

I now get a 404 not found for xx.xx.xx.xxx/login but a different log file:

[2021-06-01 07:48:47] production.INFO: db fails
[2021-06-01 07:49:31] production.INFO: SQLSTATE[HY000] [1045] Access denied for user 'ninja'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = ninja and table_name = migrations a>
[2021-06-01 07:50:24] production.INFO: db fails
[2021-06-01 07:50:49] production.INFO: account table not found
[2021-06-01 07:52:52] production.INFO: latest version = 5.1.70
[2021-06-01 07:52:52] production.INFO: latest version = 5.1.70

Though the table has definitely been created:

+-------------------------------+
| Tables_in_ninjadb             |
+-------------------------------+
| accounts                      |
| activities                    |
| backups                       |
| bank_companies                |
| bank_subcompanies             |
| banks                         |
| client_contacts               |
| client_gateway_tokens         |
| client_subscriptions          |
| clients                       |
| companies                     |
| company_gateways              |
| company_ledgers               |
| company_tokens                |
| company_user                  |
| countries                     |
| credit_invitations            |
| credits                       |
| currencies                    |
| date_formats                  |
| datetime_formats              |
| designs                       |
| documents                     |
| expense_categories            |
| expenses                      |
| failed_jobs                   |
| gateway_types                 |
| gateways                      |
| group_settings                |
| industries                    |
| invoice_invitations           |
| invoices                      |
| jobs                          |
| languages                     |
| licenses                      |
| migrations                    |
| password_resets               |
| payment_hashes                |
| payment_libraries             |
| payment_terms                 |
| payment_types                 |
| paymentables                  |
| payments                      |
| products                      |
| projects                      |
| quote_invitations             |
| quotes                        |
| recurring_invoice_invitations |
| recurring_invoices            |
| recurring_quotes              |
| sizes                         |
| subscriptions                 |
| system_logs                   |
| task_statuses                 |
| tasks                         |
| tax_rates                     |
| timezones                     |
| users                         |
| vendor_contacts               |
| vendors                       |
| webhooks                      |
+-------------------------------+

It seems to my (very inexpert) eye like there is some error in the .env:

APP_NAME="Invoice Ninja"
APP_ENV=production
APP_KEY=base64:eB8ufNvz9JXo3lJLRnX8EKpcNHnjmorPfPVV7XiaF7Y=
APP_DEBUG=false

APP_URL=http://re.da.ct.ed/

DB_CONNECTION=db-ninja-01
MULTI_DB_ENABLED=false

DB_HOST1=localhost
DB_DATABASE1=ninjadb
DB_USERNAME1=ninja
DB_PASSWORD1=ninjapass
DB_PORT1=3306

DB_HOST2=localhost
DB_DATABASE2=ninja2
DB_USERNAME2=ninja
DB_PASSWORD2=ninja
DB_PORT2=3306

DEMO_MODE=false

BROADCAST_DRIVER=log
LOG_CHANNEL=stack
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_HOST=
MAIL_PORT=
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=
MAIL_FROM_NAME=

POSTMARK_API_TOKEN=
REQUIRE_HTTPS=true

GOOGLE_MAPS_API_KEY=
ERROR_EMAIL=
TRUSTED_PROXIES=

NINJA_ENVIRONMENT=selfhost

#options - snappdf / phantom / hosted_ninja
PDF_GENERATOR=phantom

PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address'
PHANTOMJS_SECRET=secret

UPDATE_SECRET=secret

COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'

same problem, 500 Error After setup script (After clicking Submit)
tables gets created (61) but no data

[2021-06-03 14:19:35] production.ERROR: Too few arguments to function App\Jobs\Account\CreateAccount::__construct(), 1 passed in /datadrive/mydomain.co.uk/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php on line 69 and exactly 2 expected {“exception”:"[object] (ArgumentCountError(code: 0): Too few arguments to function App\Jobs\Account\CreateAccount::__construct(), 1 passed in /datadrive/mydomain.co.uk/httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Bus/Dispatchable.php on line 69 and exactly 2 expected at /datadrive/mydomain.co.uk/httpdocs/app/Jobs/Account/CreateAccount.php:47)

OS: Ubuntu 18.04.5 LTS
Plesk Obsidian 18.0.35 Update #2,
mysql 10.2.38+maria~bionic
apache 2.4.29-1ubuntu4.14

PHP 7.3.28 and 8.0.5
memory_limit 2048M
max_execution_time 360
max_input_time 360

older version installed without a problem v5.1.50-C46
trying to upgrade, nothing happens… with the following error:

[2021-06-03 15:55:02] production.INFO: latest version = 5.1.70
[2021-06-03 15:55:02] production.ERROR: /datadrive/mydomain.co.uk/httpdocs/bootstrap/cache/routes-v7.php {“userId”:1,“exception”:"[object] (App\Exceptions\FilePermissionsFailure(code: 0): /datadrive/mydomain.co.uk/httpdocs/bootstrap/cache/routes-v7.php at /datadrive/mydomain.co.uk/httpdocs/app/Http/Controllers/SelfUpdateController.php:108)

updated manually, to 5.1.70 … looks like all working fine
apart from incorrectly identifying problem with Open Basedir when using php 8
image

Has anyone managed to get a working Apache2 configuration for the migration ie both V4 & V5 implementations working simultaenously?

It seems non-trivial to me. Please post your .conf if you have - I’m sure it will be useful to others.

Glad to Say - I’ve got the two (v4 / v5) implementations working individually, but not simultaenously. It seems to come down to SSL niggles when on a single IP.

V5 does not seem to work on HTTP (throws server errors, even with FORCE HTTPS off), only on HTTPS the setup script completes.

In attempting to run V4 on HTTP my env was wiped - so I’ve lost my APPKEY - meaning payment gateways are goosed - take a backup of your V4 .env, not just a mysql dump before migration kids! - but perhaps @hillel you can maybe confirm if this won’t effect the migration - if I can get the two working together…

Here’s my working Apache2 .conf files for v5, if anyone needs them:

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin admin@example.com
        DocumentRoot /var/www/html/ninjav5/public
        #DocumentRoot /var/www/invoice-ninja/public
        ServerName *****.co.uk
        ServerAlias *****.co.uk

        <Directory /var/www/html/ninjav5/public>
        #<Directory /var/www/invoice-ninja/public>
                Options +FollowSymlinks
                AllowOverride All
                Require all granted
        </Directory>

        <FilesMatch \.php$>
                # For Apache version 2.4.10 and above, use SetHandler to run PHP as a fastCGI process server
                SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
        </FilesMatch>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile *****/fullchain.pem
        SSLCertificateKeyFile *****/privkey.pem
</VirtualHost>
</IfModule>

I think you’d need to manually mark the gateways as deleted in the account_gateways table

Grand thanks @hillel - I’m still struggling to get the two implementations to work on one server anyway.

Is it an option to download a CSV for each table - through the V4 export, clients.csv, invoices.csv etc and manually upload?

If you’re using both apps on the save server you’ll need to use PHP 7.3.

It may be possible to import/export some data as CSV but the results will be much worse than using the migration tool.

Aye - it’s a shame, but may just have to be what it is.

I’m just hitting brick wall after brick wall with trying to use the migration method - it’s definitely beyond my linux skillset to use the official path.

Are you using the latest versions of v4 and v5?

Yeah, I am. my problems are from getting the two implementations to run simultaenously on a single server and with a single SSL certificate - If the app was baked into V5, and looked back at the V4 database for the migration, for example, with a database login, then it would remove the need to have 2 virtualhosts - it’s not worth doing just for an apache challenged individual like myself though!

I tried to do a port based serve, but that was giving conflicts too. If there is an apache guru in here, they could maybe write a howto that could help folk out.

Cheers for all your hard work, and we love the app!

i am getting HTTP error 500 using your apache vhost sample