gana2188 / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 0 forks source link

Linux's PHP runtime binary #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
When attempting to locally launch a PHP runtime environment using a Linux 
machine devappserver2.py fails to find Linux's PHP runtime binary.

What is the expected output? What do you see instead?
Upon launch, we expect the binary to be identified and the local instance 
started. Instead we see the following:

>>> gcloud preview app run .
Module [default] found in file [app.yaml]
INFO: Skipping SDK update check.
INFO: Starting API server at: http://localhost:57753
INFO: Starting module "default" running at: http://localhost:8080
ERROR: The PHP runtime is not available
Traceback (most recent call last):
  File "/opt/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 222, in new_instance
    self._runtime_config_getter().application_root)
  File "/opt/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 147, in _check_environment
    'flag (%s) does not exist.' % php_executable_path)
_PHPBinaryError: The path specified with the --php_executable_path flag () does 
not exist.
INFO: Starting admin server at: http://localhost:8000

What is the output of 'gcloud info'?
Google Cloud SDK [0.9.33]

Platform: [Linux, x86_64]
Python Version: [2.7.6 (default, Mar 22 2014, 22:59:56)  [GCC 4.8.2]]
Site Packages: [Disabled]

Installation Root: [/opt/google-cloud-sdk]
Installed Components:
  core: [2014.09.30]
  app-engine-python: [1.9.12]
  core-nix: [2014.09.30]
  compute: [2014.09.30]
  gae-python: [2014.05.06]
  app-engine-go-linux-x86_64: [1.9.12]
  app-engine-java: [1.9.12]
  gsutil-nix: [4.6]
  app-engine-python-extras: [1.9.6]
  gsutil: [4.6]
  bq: [2.0.18]
  dns: [2014.09.02]
  sql: [2014.09.30]
  gcutil: [1.16.5]
  preview: [2014.09.30]
  app: [2014.09.30]
  gcutil-nix: [1.16.5]
  bq-nix: [2.0.18]
System PATH: [omitted]
Cloud SDK on PATH: [True]

Please provide any additional information below.

devappserver2.py looks for the PHP binary with the _get_default_php_path() 
function. If statements against python's sys.platform output is only validating 
'darwin' and 'win32'. For linux support, I was able to add 'linux2' to the 
'darwin' elif statement (maybe use a str.match for 'linux' to support the 
various distributions?). 

From Linux Mint 17:
>>> import sys
>>> print sys.platform
linux2

platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py

  elif sys.platform in ('darwin', 'linux2'):
    base_paths = [os.path.realpath(sys.argv[0]), sys.argv[0]]
    for base_path in base_paths:
      default_php_executable_path = os.path.abspath(
          os.path.join(os.path.dirname(os.path.dirname(base_path)), 'php-cgi'))
      if os.path.exists(default_php_executable_path):
        break
      elif os.path.exists('/usr/bin/php-cgi'):
        default_php_executable_path ='/usr/bin/php-cgi'
        break  

Original issue reported on code.google.com by J.MilesM...@gmail.com on 10 Oct 2014 at 4:59

GoogleCodeExporter commented 9 years ago
We do not ship a PHP binary with the Cloud SDK on linux (you need to build / 
install one manually).  Once you do this, you can simply use the 
--php-executable-path on `gcloud preview app run` to point to the location of 
the php binary.

Original comment by markp...@google.com on 10 Oct 2014 at 6:27