Testing php script on google app engine

On last post I’ve wrote about howto install the google app SDK for PHP . Today I want to continue with simple testing.

How to run php script using google app engine on my Ubuntu 13.04 desktop :

1. Setting PATH to google app engine by edit .profile

$ cd
$ nano .profile

add this line :

PATH=”$HOME/google_appengine:$PATH”

save.

2. Export the PATH for current operation

$ export PATH=”$HOME/google_appengine:$PATH”
$ echo $PATH

”/home/alamsyah/google_appengine:/home/alamsyah/android-sdk-linux/tools:/home/alamsyah/android-sdk-linux/platforms:/home/alamsyah/android-sdk-linux/platform-tools:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games”

3. Create testing directory

$ mkdir digitalfusi

4. Create php script

$ nano digitalfusi/index.php

put these lines :

<?php

echo “Hello world from rasyid.net <p>”;

phpinfo();

?>

save.

5. Create yaml file (configuration file).

$ nano digitalfusi/app.yaml

Put these lines :

application: digitalfusi

version: 1
runtime: php
api_version: 1

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

save. For full list of yaml option you can refer to this link.

6. Run the script

Google app engine need to know which php-cgi that work.

if you use php-cgi from ubuntu stock you can run the server using this command :

$ google_appengine/dev_appserver.py –php_executable_path=/usr/bin/php-cgi digitalfusi

INFO     2013-11-23 06:50:46,610 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-11-23 06:50:59,891 sdk_update_checker.py:261] Update check failed: HTTP Error 404: Not Found
INFO     2013-11-23 06:50:59,927 api_server.py:138] Starting API server at: http://localhost:39378
INFO     2013-11-23 06:50:59,951 dispatcher.py:171] Starting module “default” running at: http://localhost:8080
INFO     2013-11-23 06:50:59,961 admin_server.py:117] Starting admin server at: http://localhost:8000

Selection 007 Testing php script on google app engine

Using previous location of php-cgi :

$ google_appengine/dev_appserver.py –php_executable_path=$HOME/php-5.4.22/installdir/bin/php-cgi digitalfusi

INFO     2013-11-23 06:47:20,067 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-11-23 06:47:27,422 sdk_update_checker.py:261] Update check failed: HTTP Error 404: Not Found
INFO     2013-11-23 06:47:27,452 api_server.py:138] Starting API server at: http://localhost:46100
INFO     2013-11-23 06:47:27,477 dispatcher.py:171] Starting module “default” running at: http://localhost:8080
INFO     2013-11-23 06:47:27,482 admin_server.py:117] Starting admin server at: http://localhost:8000

Selection 006 Testing php script on google app engine