Initial Setup crashes with Servererror 500

Hello,

i tried installing Neos on my shared hosting.
Composer download of Neos worked as intended.

My Domain points to die “Web” directory of Neos.
After opening the URL www.mydomain.de/setup i see the green box saying Initialising Setup ... We are now redirecting you to the setup. This might take 10-60 seconds on the first run, because the application needs to build up various caches.

After that i run into an error 500. :frowning:

In my Settings.yaml i sat phpBinaryPathAndFilename: '/usr/local/pd-admin2/bin/php-7.1-cli'

when i try to run a simple command on the commandline i get:

php-7.1 ./flow --help

X-Powered-By: PHP/7.1.19
Content-type: text/html; charset=UTF-8
The Neos Flow command line script or sub process was executed with a 'cgi-fcgi' PHP binary. Make sure that you specified a CLI capable PHP binary in your PATH or Flow's Settings.yaml.

Do you guys have a clue what could be wrong here?

Welcome Jan,

Can you post the exact error message the setup gives you? You should also get a dump file in /Data/Logs/Exceptions.
Regarding that CLI issue: The version of PHP you’re running flow with is a CGI version, meaning it cannot run CLI apps such as flow. Try explicitly using the PHP CLI binary you also set in the settings:
/usr/local/pd-admin2/bin/php-7.1-cli flow <command> might work.

Some background info: The phpBinaryPathAndFilename config setting is used by Flow to process subrequests, meaning Flow calls itself via PHP’s exec() function to perform certain bootstrap tasks. It’s still necessary to perform the initial CLI request - the one you’re submitting by sending a CLI command - with the correct PHP version, because Flow obviously can’t change by which PHP version it is called.

Hello Bastian,

thanks fpr your help. The setup starts when i open www.myurl.de/setup in my browser with the green box i described above. Some seconds after that i get the Apache default Errormessage for the 500 - ‘Internal server error’. Nothing else. :frowning:

After your hint i tried the following: $ /usr/local/pd-admin2/bin/php-7.1-cli ./flow --help
Which resulted in:

X-Powered-By: PHP/7.1.19
Content-type: text/html; charset=UTF-8

The Neos Flow command line script or sub process was executed with a
'cgi-fcgi' PHP binary. Make sure that you specified a CLI capable PHP
binary in your PATH or Flow's Settings.yaml.

  Type: Neos\Flow\Core\Booting\Exception\SubProcessException
  Code: 1355480641
  File: Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php
  Line: 677

Open Data/Logs/Exceptions/201807251535390d6912.txt for a full stack trace.

The mentioned Exceptionlog from Data/Logs/Exceptions is:

Exception #1355480641 in line 347 of /home/usrdbk/www.mydomain.de/Neos/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php: X-Powered-By: PHP/7.1.19
Content-type: text/html; charset=UTF-8

The Neos Flow command line script or sub process was executed with a 'cgi-fcgi' PHP binary. Make sure that you specified a CLI capable PHP binary in your PATH or Flow's Settings.yaml.



    [array] => 

Yes, the arraydump is empty…

So i guess i have to contact my provider and ask for another binary - or?

What I find extremely weird is that

X-Powered-By: PHP/7.1.19
Content-type: text/html; charset=UTF-8

at the top of the CLI response. I don’t really have an explanation for this, it’s definitely not generated by Flow. They might have some weird version of PHP that outputs this by default? Yes, talking to your provider might be the way to go here…

because it’s php-fcgi binary, which is supposed to output HTTP.

I would bluntly say that hoster is bad for providing a binary that they even called php-cli but which is actually not CLI…

What is the output of:
/usr/local/pd-admin2/bin/php-7.1-cli -v

Hey, thanks for the replies.

The output questioned by Christian is:

$ /usr/local/pd-admin2/bin/php-7.1-cli -v

PHP 7.1.19 (cli) (built: Jun 25 2018 20:21:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Well then that looks actually good and correct. Did you also setup that PHP path in the Settings?

Mh… yes it looks like this:

#
# Example Settings
#
# This file can contain settings for your Flow application that override
# the various defaults defined by other packages.
#
# Copy this file to Settings.yaml, and adjust as necessary.
#
# For possible configuration options you may refer to the packages'
# default settings file(s) in the corresponding package directories (for
# example, Packages/Framework/Neos.Flow/Configuration/Settings.yaml)
# or read the fine manuals.

Neos:
  Flow:
    persistence:

      # It is good practice to not specify user name and password of the database
      # connection in this global Settings.yaml file. Rather specify them in the
      # settings of the respective context (Production / Development ...).
      # For a reference of the possible options, take a look at
      # https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html
      backendOptions:
        driver: 'pdo_mysql'  # use pdo_pgsql for PostgreSQL
        charset: 'utf8mb4'   # change to utf8 when using PostgreSQL
        host: '127.0.0.1'    # adjust to your database host

    # The following lines register the Flow default routes
    # For productive use you should move this setting to the main package of this
    # application and/or create custom routes.
    mvc:
      routes:
        'Neos.Flow': TRUE

  # You might need to uncomment the following lines and specify
  # the location of the PHP binary manually.
    core:
      phpBinaryPathAndFilename: '/usr/local/pd-admin2/bin/php-7.1-cli'

Hey @jafix,
What happens if you run

/usr/local/pd-admin2/bin/php-7.1-cli -r "echo PHP_SAPI;"

It should output “cli”.
Next step would be to run

/usr/local/pd-admin2/bin/php-7.1-cli flow configuration:show --type Settings --path Neos.Flow.core.phpBinaryPathAndFilename

and see what that does? It should display the path to your PHP binary. If it does not, your config is not loaded property. In which file did you make the settings above?

/usr/local/pd-admin2/bin/php-7.1-cli -r "echo PHP_SAPI;"
outputs
cli

/usr/local/pd-admin2/bin/php-7.1-cli flow configuration:show --type Settings --path Neos.Flow.core.phpBinaryPathAndFilename
X-Powered-By: PHP/7.1.20
Content-type: text/html; charset=UTF-8

The Neos Flow command line script or sub process was executed with a
'cgi-fcgi' PHP binary. Make sure that you specified a CLI capable PHP
binary in your PATH or Flow's Settings.yaml.

  Type: Neos\Flow\Core\Booting\Exception\SubProcessException
  Code: 1355480641
  File: Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php
  Line: 677

Open Data/Logs/Exceptions/20180801150239a5df9c.txt for a full stack trace.

Exception .txt file says:

Exception #1355480641 in line 347 of /home/usrdbk/www.mydomain.de/Neos/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php: X-Powered-By: PHP/7.1.20
Content-type: text/html; charset=UTF-8

The Neos Flow command line script or sub process was executed with a 'cgi-fcgi' PHP binary. Make sure that you specified a CLI capable PHP binary in your PATH or Flow's Settings.yaml.



    [array] =>

Copied Settings.yaml.example to Settings.yaml in Configuration dir and made changes there.

Hey Jan,
did you remove all Caches (rm -rf Data/Temporary) before you re-ran this? If not, does that help?

Hey,

no - i did not. But after i did i got an other output:

$ rm -rf Data/Temporary/*
$ /usr/local/pd-admin2/bin/php-7.1-cli flow configuration:show --type Settings --path Neos.Flow.core.phpBinaryPathAndFilename

Configuration "Settings: Neos.Flow.core.phpBinaryPathAndFilename":

/usr/local/pd-admin2/bin/php-7.1-cli

Aha! Well that looks like progress. Are you able to run the setup now?

Mh… no. When i call www.myurl.com/setup I get a red Box saying:

Environment requirements not fulfilled
The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect or not a PHP command line (cli) version.

But didn’t we check for the right path?

We did, so this is a bit surprising. The responsible code in the RequestHandler is this:

exec($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;"', $phpVersionString);
[...]
if (!isset($phpVersionString[0]) || strpos($phpVersionString[0], '(cli)') === false) {
    return new Error('The specified path to your PHP binary (see Configuration/Settings.yaml) is incorrect or not a PHP command line (cli) version.', 1341839376, [], 'Environment requirements not fulfilled');
}

So it basically runs the following CLI command:

/usr/local/pd-admin2/bin/php-7.1-cli -r "echo '(' . php_sapi_name() . ') ' . PHP_VERSION;"

For me, this outputs (cli) 7.1.16. Can you check what it does for you?
If you have access to the code on the server, you could also put a var_dump($phpVersionString); die; there and see what the actual output is that Flow returns.

OK, so here we go:

$ /usr/local/pd-admin2/bin/php-7.1-cli -r "echo '(' . php_sapi_name() . ') ' . PHP_VERSION;"

(cli) 7.1.20

When i add the
var_dump($phpVersionString);die();
in
./Packages/Application/Neos.Setup/Classes/Core/RequestHandler.php Line 189
i get:
array(0) { }

Then i tried to reproduce the command using:
var_dump($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;"');
and got:
string(92) ""/usr/local/pd-admin2/bin/php-7.1-cli" -r "echo '(' . php_sapi_name() . ') ' . PHP_VERSION;""

Looks like exec() is not returning the proper result. This might have to do with your server config - maybe exec() is not allowed, which some hosts do. I’m not sure how a host behaves in those cases, since server config is not my strong side. But you can pass in a third variable into exec, which will return the exit code of the command - like this:

exec($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;"', $phpVersionString, $exitCode);
var_dump($exitCode);
die;

Does that return anything? Maybe that gets us somewhere. You could also try if exec works just by pasting that snippet into a new file named “foo.php” and running it with /usr/local/pd-admin2/bin/php-7.1-cli foo.php:

<?php
exec('echo "foo"', $result, $status);
var_dump($result);
var_dump($status);

Your output here should be:

array(1) {
  [0]=>
  string(3) "foo"
}
int(0)

Good morning!

Ok, the dump of the exit code via

exec($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;"', $phpVersionString, $exitCode);
var_dump($exitCode);
die;

returned: int(2)

And the foo.php got the desired output:

$ /usr/local/pd-admin2/bin/php-7.1-cli foo.php
array(1) {
  [0]=>
  string(3) "foo"
}
int(0)

I was unsatisfied with the pure exitcode 2, so i did a bit of googleing and trying and ended up like this in my RequestHandler:

exec($phpCommand . ' -r "echo \'(\' . php_sapi_name() . \') \' . PHP_VERSION;" 2>&1', $phpVersionString, $exitCode);
var_dump($phpVersionString);
var_dump($exitCode);
die;

which returns:

array(1) { [0]=> string(18) "sh: 1: Cannot fork" }
int(2)

Does that tell you more?

Nope, sorry - I’m out of my depth here. I suggest at this point you talk to your hoster :wink:
One last thing to check maybe: You can move the foo.php into your Flow app’s Web directory and access it via http://yourdomain.com/foo.php. If this returns int(2) as exit code also, we know pretty precisely what the issue is - exec() works on the CLI, but not on a web request.

Whohooo… step further… after digging google again und crossing out one result after another: I had about 100 processes hanging from my further tryouts and so the system said - nope no more forks… :slight_smile:

So, i killed them, cleared temporary data again and now the setup starts! Yippie!

BUT, after entering my DB credentials (empty mysql db, utf8mb4_general_ci) I get an exception, saying:

An exception occurred while executing ‘CREATE TABLE flow3_resource_resourcepointer (hash VARCHAR(255) NOT NULL, PRIMARY KEY(hash)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB’:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

The exception details have been logged to the Flow system log.
Exception in line 184 of /home/usrdbk/www.myurl.de/Neos/Packages/Libraries/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php: An exception occurred while executing ‘CREATE TABLE flow3_resource_resourcepointer (hash VARCHAR(255) NOT NULL, PRIMARY KEY(hash)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB’:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes - See also: 20180802102319a581b4.txt

Exception Code 1355480641
Exception Type Neos\Flow\Core\Booting\Exception\SubProcessException
Log Reference 20180802102319bbc967
Thrown in File Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php
Line 677