Unable to get Google App Engine PHP tutorial worki

2019-02-18 23:42发布

问题:

I'm following the GAE PHP tutorial but I can't get the local dev server to respond properly.

I run it with

dev_appserver.py --php_executable_path=/usr/bin/php --host=192.168.33.44 ./

and it starts up fine. When I view http://192.168.33.44:8080/ the logs show

INFO 2016-10-12 07:55:06,264 module.py:788] default: "GET / HTTP/1.1" 200 -

but I get a blank page. There's nothing in the tutorial explaining what to do if you have problems.

So far, I've:

  • Tried PHP 5.5 and 5.6 (remi): no difference
  • Put corrupt PHP in helloworld.php: no errors
  • Changed the handler to - url: /: blank page on /, 404 page for any other URL
  • Scoured Google Docs: no help
  • Scoured Google: no help
  • Asked the rubber duck: no help

I'm running Centos 7.2 via Vagrant and Google Cloud SDK 129.0.0.

Any and all help greatly appreciated.

[EDIT]

Additional data as requested

$ which php
/usr/bin/php


$ /usr/bin/php -v
PHP 5.5.38 (cli) (built: Sep 19 2016 13:45:10)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies


$ which python
/usr/bin/python


$ /usr/bin/python -V
Python 2.7.5

$ cat app.yaml
runtime: php55
api_version: 1

handlers:
- url: /.*
  script: helloworld.php


$ cat helloworld.php
<?php

echo 'Hello, World!';


$ dev_appserver.py --php_executable_path=/usr/bin/php --host=192.168.33.44 ./


Updates are available for some Cloud SDK components.  To install them, please run:
$ gcloud components update

INFO     2016-10-13 08:21:22,699 devappserver2.py:769] Skipping SDK update check.
INFO     2016-10-13 08:21:22,730 api_server.py:205] Starting API server at: http://localhost:46453
INFO     2016-10-13 08:21:22,737 dispatcher.py:197] Starting module "default" running at: http://192.168.33.44:8080
INFO     2016-10-13 08:21:22,738 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO     2016-10-13 08:21:34,142 module.py:788] default: "GET / HTTP/1.1" 200 -

Response Headers from Chrome when accessing http://192.168.33.44:8080/

Cache-Control: no-cache
Content-Length: 0
Content-Type: text/html
Date: Thu, 13 Oct 2016 08:21:34 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Server: Development/2.0

I updated from 129 to 130 but the same problem exists

回答1:

Turns out the problem was a trivial oversight...

dev_appserver.py --php_executable_path=/usr/bin/php --host=192.168.33.44 ./

Should have been

dev_appserver.py --php_executable_path=/usr/bin/php-cgi --host=192.168.33.44 ./

The App Engine requires the php-cgi binary, not the cli one. Ended up stumbling over it in the docs a while ago, but forgot to come back here and post the answer