Undefined index: SERVER_PROTOCOL

Trying to install Silverstripe on a Synology NAS (Apache or Nginx, PHP 7.4)
I’m getting

PHP Notice: Undefined index: SERVER_PROTOCOL in /volume1/web/markt/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 388
ERROR [Notice]: Undefined index: SERVER_PROTOCOL
IN Line 388 in /volume1/web/markt/vendor/silverstripe/framework/src/Control/HTTPResponse.php
What can I do?

Judging by the fact that you created this thread afterwards which you seem to have resolved: Installing Silverstripe on Synology NAS
Have you resolved this as well?

Thank you for your reaction.
Very strange behaviour indeed. When I run the Silverstripe app everything works fine.
However, opening PuTTy, going to the /public folder and executing php index.php, I get the output below.

Francis@FFserv:/var/services/web/market/public$ php index.php
PHP Notice: Undefined index: SERVER_PROTOCOL in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 388
ERROR [Notice]: Undefined index: SERVER_PROTOCOL
IN
Line 388 in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source

379: /**
380: * Output HTTP headers to the browser
381: */
382: protected function outputHeaders()
383: {
384: $headersSent = headers_sent($file, $line);
385: if (!$headersSent) {
386: $method = sprintf(
387: “%s %d %s”,

  • 388: $_SERVER[‘SERVER_PROTOCOL’],
    389: $this->getStatusCode(),
    390: $this->getStatusDescription()
    391: );
    392: header($method ?? ‘’);
    393: foreach ($this->getHeaders() as $header => $value) {
    394: header("{$header}: {$value}", true, $this->getStatusCode() ?? 0);

Trace

Monolog\ErrorHandler->handleError(8, Undefined index: SERVER_PROTOCOL, /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php, 388, Array)
HTTPResponse.php:388

SilverStripe\Control\HTTPResponse->outputHeaders()
HTTPResponse.php:351

SilverStripe\Control\HTTPResponse->output()
index.php:25

[2022-12-12 21:29:15] error-log.NOTICE: E_NOTICE: Undefined index: SERVER_PROTOCOL {“code”:8,“message”:“Undefined index: SERVER_PROTOCOL”,“file”:"/volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php",“line”:388}
PHP Notice: Undefined index: SERVER_PROTOCOL in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 388
ERROR [Warning]: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)
IN
Line 392 in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source

383: {
384: $headersSent = headers_sent($file, $line);
385: if (!$headersSent) {
386: $method = sprintf(
387: “%s %d %s”,
388: $_SERVER[‘SERVER_PROTOCOL’],
389: $this->getStatusCode(),
390: $this->getStatusDescription()
391: );

  • 392: header($method ?? ‘’);
    393: foreach ($this->getHeaders() as $header => $value) {
    394: header("{$header}: {$value}", true, $this->getStatusCode() ?? 0);
    395: }
    396: } elseif ($this->getStatusCode() >= 300) {
    397: // It’s critical that these status codes are sent; we need to report a failure if not.
    398: user_error(

Trace

header( 200 OK)
HTTPResponse.php:392

SilverStripe\Control\HTTPResponse->outputHeaders()
HTTPResponse.php:351

SilverStripe\Control\HTTPResponse->output()
index.php:25

[2022-12-12 21:29:15] error-log.WARNING: E_WARNING: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) {“code”:2,“message”:“Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)”,“file”:"/volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php",“line”:392}
PHP Warning: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 392
ERROR [Warning]: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)
IN
Line 394 in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source

385: if (!$headersSent) {
386: $method = sprintf(
387: “%s %d %s”,
388: $_SERVER[‘SERVER_PROTOCOL’],
389: $this->getStatusCode(),
390: $this->getStatusDescription()
391: );
392: header($method ?? ‘’);
393: foreach ($this->getHeaders() as $header => $value) {

  • 394: header("{$header}: {$value}", true, $this->getStatusCode() ?? 0);
    395: }
    396: } elseif ($this->getStatusCode() >= 300) {
    397: // It’s critical that these status codes are sent; we need to report a failure if not.
    398: user_error(
    399: sprintf(
    400: “Couldn’t set response type to %d because of output on line %s of %s”,

Trace

header(content-type: text/html; charset=utf-8, 1, 200)
HTTPResponse.php:394

SilverStripe\Control\HTTPResponse->outputHeaders()
HTTPResponse.php:351

SilverStripe\Control\HTTPResponse->output()
index.php:25

[2022-12-12 21:29:15] error-log.WARNING: E_WARNING: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) {“code”:2,“message”:“Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)”,“file”:"/volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php",“line”:394}
PHP Warning: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 394
ERROR [Warning]: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)
IN
Line 394 in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source

385: if (!$headersSent) {
386: $method = sprintf(
387: “%s %d %s”,
388: $_SERVER[‘SERVER_PROTOCOL’],
389: $this->getStatusCode(),
390: $this->getStatusDescription()
391: );
392: header($method ?? ‘’);
393: foreach ($this->getHeaders() as $header => $value) {

  • 394: header("{$header}: {$value}", true, $this->getStatusCode() ?? 0);
    395: }
    396: } elseif ($this->getStatusCode() >= 300) {
    397: // It’s critical that these status codes are sent; we need to report a failure if not.
    398: user_error(
    399: sprintf(
    400: “Couldn’t set response type to %d because of output on line %s of %s”,

Trace

header(vary: X-Forwarded-Protocol, 1, 200)
HTTPResponse.php:394

SilverStripe\Control\HTTPResponse->outputHeaders()
HTTPResponse.php:351

SilverStripe\Control\HTTPResponse->output()
index.php:25

[2022-12-12 21:29:15] error-log.WARNING: E_WARNING: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) {“code”:2,“message”:“Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)”,“file”:"/volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php",“line”:394}
PHP Warning: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 394
ERROR [Warning]: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)
IN
Line 394 in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php

Source

385: if (!$headersSent) {
386: $method = sprintf(
387: “%s %d %s”,
388: $_SERVER[‘SERVER_PROTOCOL’],
389: $this->getStatusCode(),
390: $this->getStatusDescription()
391: );
392: header($method ?? ‘’);
393: foreach ($this->getHeaders() as $header => $value) {

  • 394: header("{$header}: {$value}", true, $this->getStatusCode() ?? 0);
    395: }
    396: } elseif ($this->getStatusCode() >= 300) {
    397: // It’s critical that these status codes are sent; we need to report a failure if not.
    398: user_error(
    399: sprintf(
    400: “Couldn’t set response type to %d because of output on line %s of %s”,

Trace

header(cache-control: no-cache, no-store, must-revalidate, 1, 200)
HTTPResponse.php:394

SilverStripe\Control\HTTPResponse->outputHeaders()
HTTPResponse.php:351

SilverStripe\Control\HTTPResponse->output()
index.php:25

[2022-12-12 21:29:15] error-log.WARNING: E_WARNING: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) {“code”:2,“message”:“Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427)”,“file”:"/volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php",“line”:394}
PHP Warning: Cannot modify header information - headers already sent by (output started at /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php:427) in /volume1/web/market/vendor/silverstripe/framework/src/Control/HTTPResponse.php on line 394

Home » Het Stratégem
    <link rel="shortcut icon" href="themes/simple/images/favicon.ico" />

Het Stratégem

                            <p>Adviesbureau voor identiteit en kansenmanagement</p>

                    </a>

                    <nav class="primary">
    <span class="nav-open-button">²</span>
    <ul>

                    <li class="current"><a href="/" title="Home">Home</a></li>

                    <li class="link"><a href="/het-strategem/" title="Het Stratégem">Het Stratégem</a></li>

                    <li class="link"><a href="/diensten-en-producten/" title="Diensten en Producten">Diensten en Producten</a></li>

                    <li class="link"><a href="/netwerk-en-samenwerkingen/" title="Netwerk en Samenwerkingen">Netwerk en Samenwerkingen</a></li>

                    <li class="link"><a href="/over-wim-de-vries/" title="Over Wim de Vries">Over Wim de Vries</a></li>

                    <li class="link"><a href="/bekijk-de-presentatie/" title="Bekijk de presentatie">Bekijk de presentatie</a></li>

                    <li class="link"><a href="/contact/" title="Contact">Contact</a></li>

    </ul>
            </div>
    </div>
Het Stratégem ²
                    <li class="current"><a href="/" title="Home">Home</a></li>

                    <li class="link"><a href="/het-strategem/" title="Het Stratégem">Het Stratégem</a></li>

                    <li class="link"><a href="/diensten-en-producten/" title="Diensten en Producten">Diensten en Producten</a></li>

                    <li class="link"><a href="/netwerk-en-samenwerkingen/" title="Netwerk en Samenwerkingen">Netwerk en Samenwerkingen</a></li>

                    <li class="link"><a href="/over-wim-de-vries/" title="Over Wim de Vries">Over Wim de Vries</a></li>

                    <li class="link"><a href="/bekijk-de-presentatie/" title="Bekijk de presentatie">Bekijk de presentatie</a></li>

                    <li class="link"><a href="/contact/" title="Contact">Contact</a></li>

    </ul>
Theme by Sara (Innovatif) / Powered by SilverStripe

This is not supported behaviour. It’s expected that you’ll use a webserver to dish out the site (Apache is recommended) - or if you want to run command-line tools, you can use sake (./vendor/bin/sake).

Thank you Guy.
I now understand that executing php index.php is not supported, but initially I was so much puzzled by the way the installation proceeded that I tried it a.o. to see if the database was accessed. And then, seeing the errors I presumed this could be reason for my trouble. It clearly wasn’t.
Sorry for my mistake. You may close the subject or even remove it if you think it’s bringing others to bad ideas.

Regards,
Francis

1 Like