jan
jan

Reputation: 875

How to set up Google App Engine PHP SDK on Ubuntu

I tried to follow the instructions on https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP

When I start up the app engine with the hello world example like this:

go_appengine/dev_appserver.py --php_executable_path=/home/jan/php-5.4.25/installdir/bin/php-cgi helloworld/

I get a error in the console saying: ERROR php_runtime.py:348] The PHP runtime is not available

If I go to localhost:8080, I get:

The PHP interpreter specified with the --php_executable_path flag ("/home/jan/php-5.4.25/installdir/bin/php-cgi") is not compatible with the App Engine PHP development environment.

No input file specified.

I thought maybe they just refered to an old version or something in the docs, so I also tried the same method with php 5.5.30, and even just apt-get php5-cgi changing php_executable_path each time with the same result.

This is on a fresh install of ubuntu 14.04 on a VM.

Anyone know what's going on here?

EDIT:

app.yaml

application: helloworld
version: 1
runtime: php55
api_version: 1

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

OUTPUT:

INFO     2016-01-05 12:11:42,024 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO     2016-01-05 12:11:42,299 sdk_update_checker.py:257] The SDK is up to date.
INFO     2016-01-05 12:11:42,355 api_server.py:205] Starting API server at: http://localhost:37460
INFO     2016-01-05 12:11:42,357 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2016-01-05 12:11:42,360 admin_server.py:116] Starting admin server at: http://localhost:8000
ERROR    2016-01-05 12:11:43,418 php_runtime.py:348] The PHP runtime is not available
Traceback (most recent call last):
  File "/appengine/google/appengine/tools/devappserver2/php_runtime.py", line 344, in new_instance
    self._check_binaries(php_executable_path, gae_extension_path)
  File "/appengine/google/appengine/tools/devappserver2/php_runtime.py", line 284, in _check_binaries
    cls._check_environment(php_executable_path, env)
  File "/appengine/google/appengine/tools/devappserver2/php_runtime.py", line 259, in _check_environment
    raise _PHPEnvironmentError(check_process_stdout)
_PHPEnvironmentError: No input file specified.

Upvotes: 3

Views: 1111

Answers (2)

jan
jan

Reputation: 875

Sorry, but I had downloaded the SDK for Go instead of PHP. Thank you for trying to help me.

Upvotes: 0

ojrask
ojrask

Reputation: 2828

Does the same error appear on multiple projects/apps or just one project/app? Is your app.yaml configured to display PHP pages properly?


The official documentation on this subject did not work for me either (and does not cover PHP 5.5 usage instructions).

I had to compile a custom PHP 5.5 CGI binary for my PHP SDK on Ubuntu 14.04.

Note: the following worked on my system, and there might be some variables per system which need adjusting.

Download the source for PHP 5.5.30 and open the directory in your terminal

$ cd /downloaded/php/source/dir/path

ls should display a configure file inside the directory. Then inside the source directory run a configure as follows (\ for formatting, can be left out and make the command one-line):

$ ./configure --prefix=/php/5.5/ \
    --enable-bcmath \
    --enable-calendar \
    --enable-ftp \
    --enable-mbstring \
    --enable-opcache \
    --enable-soap \
    --enable-sockets \
    --enable-zip \
    --disable-fileinfo \
    --disable-flatfile \
    --disable-posix \
    --with-curl \
    --with-gd \
    --with-openssl \
    --without-sqlite3 \
    --without-pdo-sqlite \
    --without-imap \
    --without-kerberos \
    --without-imap-ssl \
    --without-interbase \
    --without-ldap \
    --without-mssql \
    --without-oci8 \
    --without-pgsql \
    --without-pear \
    --disable-phar \
    --with-pdo-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --with-mysql=mysqlnd

Then just

$ sudo make && sudo make install

The prefix then sets the make && make install commands to install the php-cgi binary into /php/5.5/bin/php-cgi, which is the binary to use in the SDK's --php_executable_path (i.e. --php_executable_path=/php/5.5/bin/php-cgi).

Additionally, make sure the PHP SDK has the permission to run the php-cgi executable some way, e.g. chown the PHP installation to the same user who runs the SDK.

Note: if you try to install php-memcache(d) for the SDK executable, the SDK will not work with it. As far as I know the SDK uses some internal mechanism to emulate memcached usage in the dev server. Some other extensions also trigger SDK errors like this.

Upvotes: 2

Related Questions