grav icon indicating copy to clipboard operation
grav copied to clipboard

Grav and nginx-unit.

Open eleksir opened this issue 6 years ago • 7 comments

There is application server called nginx unit, it is capable to run php applications. It successfully runs wordpress, roundcube, tiny-tiny rss, etc.

But if ona wants to run Grav on this app server, it will fail with error: PHP webserver requires a router to run Grav, please use: <pre>php -S webserver.local:80 system/router.php</pre>

You just need to pick alpine linux 3.9 with it's php7, unit-php7 and nginx to reproduce this.

eleksir avatar Sep 07 '19 09:09 eleksir

Try commenting out this check https://github.com/getgrav/grav/blob/develop/index.php#L19

rhukster avatar Sep 07 '19 16:09 rhukster

if commented out - everything works fine.

eleksir avatar Sep 07 '19 20:09 eleksir

I need to find some identifier from the nginx unit so it can skip that check.

rhukster avatar Sep 07 '19 20:09 rhukster

ahhh, deeper checks discover that grav says

Error 404
PLUGIN_ERROR.ERROR_MESSAGE

how to debug it deeper - i don't know.

eleksir avatar Sep 07 '19 20:09 eleksir

logs/grav.log is empty nginx access.log says that my root url got 404 (i place grav under /wordpress/ on my site) nginx error.log is empty unit.log empty too

eleksir avatar Sep 07 '19 20:09 eleksir

I see traditional E_NOROGRESS here. It looks like there is some weirdness in directory traversal, that comes from error assumptions on "how it works". What if i dig inside this problem and find solution?

eleksir avatar Mar 31 '20 00:03 eleksir

I can confirm that I also encountered this when I tried to build a Docker image based on Nginx Unit. Commenting out the suggested check block did indeed fix this (thank you!). I can tolerate that hack while I'm still building up that image and it's just for my use.

I looked for variables in the PHP environment that might act as identifiers for @rhukster to test against but nothing stood out for me. From reading, it seems Unit should really be setting $_SERVER['PHP_CLI_ROUTER'] to 'embed'. If it did, this test would "pass".

If @eleksir is running Unit on the official docker images (no mention of docker so I'm assuming), then there is an explanation for both of us. It seems the official PHP builds for Alpine excluded the embed module. There is a process to remedy this upstream so this issue might go away if we are lucky.

hughbris avatar Jan 22 '24 00:01 hughbris