Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting Google App Engine Web Server

I'm going through the helloworld tutorial for Google App Engine using PHP (https://developers.google.com/appengine/docs/php/gettingstarted/helloworld). After getting the application set up and ready to go the tutorial tells me to start the web server included with the Google App Engine SDK using the command: google_appengine/dev_appserver.py --php_executable_path= helloworld/. How exactly do I start the web server and where do I put that command in?

like image 950
Nick Gilbert Avatar asked Oct 22 '13 19:10

Nick Gilbert


People also ask

Can I host my website on Google App Engine?

You can use Google App Engine to host a static website. Static web pages can contain client-side technologies such as HTML, CSS, and JavaScript. Hosting your static site on App Engine can cost less than using a traditional hosting provider, as App Engine provides a free tier.

How do I host a website on App Engine?

To use Google's tools for your own site or app, you need to create a new project on Google Cloud Platform. This requires having a Google account. Go to the App Engine dashboard on the Google Cloud Platform Console and press the Create button.

How do I deploy Google web app?

At the top right of the script project, click Deploy > New deployment. Next to "Select type," click Enable deployment types settings > Web app. Enter the information about your web app in the fields under "Deployment configuration." Click Deploy.


2 Answers

After you install the SDK on your machine you'll have a google_appengine directory. I run Windows so mine is located at:

C:\Program Files (x86)\Google\google_appengine

Inside that directory is a python script called "dev_appserver.py" which is what the tutorial wants you to run. Your local machine should also have PHP installed and the script is looking for the location to that since it would be something you'd install yourself.

You'll execute this script from whatever local command line application your OS has (shell for Linux, terminal in Mac, Command Prompt or Powershell in Windows).

I execute mine from the folder one level above my GAE application is stored. To ensure you can properly execute this command, run it with no parameters and you should see this:

python "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py"

Output:

usage: dev_appserver.py [-h] [--host HOST] [--port PORT]
                        [--admin_host ADMIN_HOST] [--admin_port ADMIN_PORT]
                        [--auth_domain AUTH_DOMAIN] [--storage_path PATH]
                        [--log_level {debug,info,warning,critical,error}]
                        [--max_module_instances MAX_MODULE_INSTANCES]
                        [--use_mtime_file_watcher [USE_MTIME_FILE_WATCHER]]
                        [--threadsafe_override THREADSAFE_OVERRIDE]
                        [--php_executable_path PATH]
                        [--php_remote_debugging [PHP_REMOTE_DEBUGGING]]
                        [--python_startup_script PYTHON_STARTUP_SCRIPT]
                        [--python_startup_args PYTHON_STARTUP_ARGS]
                        [--blobstore_path BLOBSTORE_PATH]
                        [--mysql_host MYSQL_HOST] [--mysql_port MYSQL_PORT]
                        [--mysql_user MYSQL_USER]
                        [--mysql_password MYSQL_PASSWORD]
                        [--mysql_socket MYSQL_SOCKET]
                        [--datastore_path DATASTORE_PATH]
                        [--clear_datastore [CLEAR_DATASTORE]]
                        [--datastore_consistency_policy {consistent,random,time}]
                        [--require_indexes [REQUIRE_INDEXES]]
                        [--auto_id_policy {sequential,scattered}]
                        [--logs_path LOGS_PATH]
                        [--show_mail_body [SHOW_MAIL_BODY]]
                        [--enable_sendmail [ENABLE_SENDMAIL]]
                        [--smtp_host SMTP_HOST] [--smtp_port SMTP_PORT]
                        [--smtp_user SMTP_USER]
                        [--smtp_password SMTP_PASSWORD]
                        [--prospective_search_path PROSPECTIVE_SEARCH_PATH]
                        [--clear_prospective_search [CLEAR_PROSPECTIVE_SEARCH]]
                        [--search_indexes_path SEARCH_INDEXES_PATH]
                        [--clear_search_indexes [CLEAR_SEARCH_INDEXES]]
                        [--enable_task_running [ENABLE_TASK_RUNNING]]
                        [--allow_skipped_files [ALLOW_SKIPPED_FILES]]
                        [--api_port API_PORT]
                        [--automatic_restart [AUTOMATIC_RESTART]]
                        [--dev_appserver_log_level {debug,info,warning,critical,error}]
                        [--skip_sdk_update_check [SKIP_SDK_UPDATE_CHECK]]
                        [--default_gcs_bucket_name DEFAULT_GCS_BUCKET_NAME]
                        yaml_files [yaml_files ...]
dev_appserver.py: error: too few arguments

My command to get this working properly was:

python "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py" --port 8082 --admin_port 8083 --php_executable_path "C:\Program Files (x86)\NuSphere\PhpED\php54\php-cgi.exe" helloworld\

I got this output in Powershell and was able to hit the local url and see "Hellow, World!"

INFO     2013-10-22 16:04:27,039 sdk_update_checker.py:245] Checking for updates to the SDK.
INFO     2013-10-22 16:04:28,368 sdk_update_checker.py:261] Update check failed: HTTP Error 404: Not Found
WARNING  2013-10-22 16:04:28,398 api_server.py:332] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO     2013-10-22 16:04:28,405 api_server.py:139] Starting API server at: http://localhost:52150
INFO     2013-10-22 16:04:28,408 dispatcher.py:171] Starting module "default" running at: http://localhost:8082
INFO     2013-10-22 16:04:28,411 admin_server.py:117] Starting admin server at: http://localhost:8083
INFO     2013-10-22 16:04:31,980 module.py:608] default: "GET / HTTP/1.1" 200 13
INFO     2013-10-22 16:04:32,223 module.py:608] default: "GET /favicon.ico HTTP/1.1" 200 13
like image 159
Chris Rasco Avatar answered Oct 05 '22 13:10

Chris Rasco


The Google cloud SDK comes with a Launcher in which you could add project files and examine the logs in the GUI. I used python code here but it should behave the same with php.

Go to Google App Engine Launcher -> Select File -> Add Existing Application -> Browse and select the root directory of your PHP/Python/Java/Go application -> Add -> Click Run button -> Click Logs

2014-12-30 01:02:57 Running command: "['C:\\Users\\gung13\\Anaconda\\pythonw.exe', 'C:\\Program Files\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=9080', '--admin_port=8001', u'C:\\Users\\gung13\\Desktop\\appengine-try-python-flask']"
INFO     2014-12-30 01:02:57,874 devappserver2.py:745] Skipping SDK update check.
INFO     2014-12-30 01:02:57,903 api_server.py:172] Starting API server at: http://localhost:62234
INFO     2014-12-30 01:02:57,905 dispatcher.py:186] Starting module "default" running at: http://localhost:9080
INFO     2014-12-30 01:02:57,907 admin_server.py:118] Starting admin server at: http://localhost:8001
INFO     2014-12-30 01:03:21,677 module.py:718] default: "GET / HTTP/1.1" 200 13
INFO     2014-12-30 01:03:21,986 module.py:718] default: "GET /favicon.ico HTTP/1.1" 404 27
like image 40
gung13 Avatar answered Oct 05 '22 14:10

gung13