Google App Engine lets you run web applications on Google's infrastructure. It is kind of a platform that you can build application from your preferred programming languages and run them on it.
This post will discuss how to install App Engine in Linux environment and set it up to do PHP applications. Not much to do... But there will be some issues occur and here talk about how to troubleshoot them...
[Following directory paths used as I preferred and you can use your own ;)]
Download Google App Engine and put it in to a location where you preferred.
[/opt/lib/google_appengine]
You can run your web applications with out doing any further things but it's easy adding this to your PATH variable in .bashrc ...
So insert following lines to .bashrc
# set GOOGLE_APP_ENGINE
export APPENGINE_SDK=/opt/lib/google_appengine (Change this path to where downloaded app engine located)
export PATH=$PATH:$APPENGINE_SDK
After doing that change directory to where your .bashrc file locate. (home folder) Execute following command...
[root ~]~$: .bashrc (This will reload new PATH you added)
Now execute command "dev_appserver.py", you can see usage parameters defined. If not some thing missing....So check what you have missed... :P
Now we ll create our HelloGoogle app from PHP and run it.
Create a directory in a workspace you preferred.
[root ~]~$: mkdir -p /home/zee/google/helloGoogle
Then create a PHP file helloGoogle.php and insert following code.
<?php
echo 'Hello Google!!!';
?>
Another file you need to create app.yaml in your helloGoogle directory. Without this your application cannot run on App Engine server. (Not going to talk about it much as this is about implementing and troubleshooting) Insert Following code in to that file.
application: helloGoogle
version: 1
runtime: php
api_version: 1
handlers:Now you can continue..................
- url: /.*
script: helloGoogle.php
Execute following command in shell to up and run the server with your application...
[root ~]~$: dev_appserver.py /home/zee/google/helloGoogle/
Go to your browser and load http://localhost:8080/ ... :)
Troubleshooting
When you trying to execute above command you may get following error....
ERROR 2014-01-31 07:53:44,617 php_runtime.py:223] The PHP runtime is not availableTraceback (most recent call last): File "/data/lib/appengine/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 219, in new_instance self._check_environment(php_executable_path) File "/data/lib/appengine/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 148, in _check_environment 'flag (%s) does not exist.' % php_executable_path)_PHPBinaryError: The path specified with the --php_executable_path flag () does not exist.
This is a bug that need to fix.....Any how as a solution execute your command as follow,
[root ~]~$: dev_appserver.py --php_executable_path=/usr/bin/php5-cgi /home/zee/google/helloGoogle/
##############For above --php_executable_path you need to find where is the php-cgi locate. Easy way for it is execute,
[root ~]~$: which php
You will find the php-cgi in result location....##############
Even you fixed it you may get another error........
ERROR 2014-01-31 07:57:19,504 php_runtime.py:223] The PHP runtime is not availableThis means you need to disable Memcache in your PHP. Better if you can install separate PHP instance for App Engine. Any how to fix this.....
Traceback (most recent call last):
File "/data/lib/appengine/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 219, in new_instance
self._check_environment(php_executable_path)
File "/data/lib/appengine/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 193, in _check_environment
raise _PHPEnvironmentError(check_process_stdout)
_PHPEnvironmentError: The PHP runtime cannot be run with the "Memcache" PECL extension installed
^CINFO 2014-01-31 07:57:23,264 shutdown.py:44] Shutting down.
Run command
[root ~]~$: php --ini
You will get list of extensions installed along with php...
/etc/php5/cli/conf.d/20-apc.ini,From that edit memcache.ini file. Comment extension=memcache.so with ;
/etc/php5/cli/conf.d/20-curl.ini,
/etc/php5/cli/conf.d/20-gd.ini,
/etc/php5/cli/conf.d/20-imap.ini,
/etc/php5/cli/conf.d/20-mcrypt.ini,
/etc/php5/cli/conf.d/20-memcache.ini,
/etc/php5/cli/conf.d/20-mysql.ini,
/etc/php5/cli/conf.d/20-mysqli.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini,
/etc/php5/cli/conf.d/20-xdebug.ini,
/etc/php5/cli/conf.d/php5-custom.ini
; uncomment the next line to enable the moduleNow things will run smoothly....... :D
;extension=memcache.so
[memcache]
memcache.dbpath="/var/lib/memcache"
memcache.maxreclevel=0
memcache.maxfiles=0
memcache.archivememlim=0
memcache.maxfilesize=0
memcache.maxratio=0
No comments:
Post a Comment