如何使用谷歌应用引擎将php项目部署到谷歌云?

时间:2018-01-11 12:33:35

标签: php google-app-engine

我是这个php开发的新手。我使用Netbeans 8.2环境开发了一个php web应用程序。我正在尝试部署应用程序,但没有在服务器上运行以获取错误。

根据googled说明:

  1. 在Google云端创建Google项目
  2. 下载了Google SDK并进行了初步设置
  3. 手动将app.yaml文件生成到我的项目目录中
  4. 在google sdk上使用gcloud app deploy命令部署项目
  5. 该应用无法确定此处缺少的内容。

    
    
    2018-01-11 17:15:05,223 DEBUG    root            Loaded Command Group: ['gcloud', 'app']
    2018-01-11 17:15:09,326 DEBUG    root            Loaded Command Group: ['gcloud', 'app', 'deploy']
    2018-01-11 17:15:09,332 DEBUG    root            Running [gcloud.app.deploy] with arguments: []
    2018-01-11 17:15:13,497 DEBUG    root            No staging command found for runtime [php] and environment [FLEX].
    2018-01-11 17:15:13,497 DEBUG    root            API endpoint: [https://appengine.googleapis.com/], API version: [v1]
    2018-01-11 17:15:16,911 INFO     ___FILE_ONLY___ Services to deploy:
    
    2018-01-11 17:15:16,913 INFO     ___FILE_ONLY___ descriptor:      [C:\xampp\htdocs\viralpermissionmodule\app.yaml]
    source:          [C:\xampp\htdocs\viralpermissionmodule]
    target project:  [permission-varal]
    target service:  [default]
    target version:  [20180111t171516]
    target url:      [https://permission-varal.appspot.com]
    
    2018-01-11 17:15:30,006 DEBUG    root            No bucket specified, retrieving default bucket.
    2018-01-11 17:15:30,105 DEBUG    root            Using bucket [gs://staging.permission-varal.appspot.com].
    2018-01-11 17:15:32,358 DEBUG    root            Service [appengineflex.googleapis.com] is already enabled for project [permission-varal]
    2018-01-11 17:15:32,757 INFO     ___FILE_ONLY___ Beginning deployment of service [default]...
    
    2018-01-11 17:15:32,759 INFO     root            Need Dockerfile to be generated for runtime php
    2018-01-11 17:15:32,759 INFO     ___FILE_ONLY___ Building and pushing image for service [default]
    
    2018-01-11 17:15:33,982 DEBUG    root            Could not call git with args ('config', '--get-regexp', 'remote\\.(.*)\\.url'): Command '['git', 'config', '--get-regexp', 'remote\\.(.*)\\.url']' returned non-zero exit status 1
    2018-01-11 17:15:33,982 INFO     root            Could not generate [source-contexts.json]: Could not list remote URLs from source directory: C:\xampp\htdocs\viralpermissionmodule
    Stackdriver Debugger may not be configured or enabled on this application. See https://cloud.google.com/debugger/ for more information.
    2018-01-11 17:15:40,645 INFO     root            Ignoring file [vendors\validator\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,650 INFO     root            Ignoring file [vendors\skycons\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,651 INFO     root            Ignoring file [vendors\select2\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,671 INFO     root            Ignoring file [vendors\select2\docs\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,723 INFO     root            Ignoring file [vendors\pnotify\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,779 INFO     root            Ignoring file [vendors\normalize-css\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,782 INFO     root            Ignoring file [vendors\morris.js\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,890 INFO     root            Ignoring file [vendors\jquery.easy-pie-chart\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,900 INFO     root            Ignoring file [vendors\jquery-knob\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,924 INFO     root            Ignoring file [vendors\ion.rangeSlider\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,963 INFO     root            Ignoring file [vendors\fontawesome\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,969 INFO     root            Ignoring file [vendors\font-awesome\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:40,980 INFO     root            Ignoring file [vendors\echarts\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:41,134 INFO     root            Ignoring file [vendors\autosize\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:41,138 INFO     root            Ignoring file [vendors\Flot\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:41,262 INFO     root            Ignoring file [vendors\Chart.js\.gitignore]: File matches ignore regex.
    2018-01-11 17:15:41,286 INFO     ___FILE_ONLY___ Some files were skipped. Pass `--verbosity=info` to see which ones.
    
    2018-01-11 17:15:41,286 INFO     ___FILE_ONLY___ You may also view the gcloud log file, found at
    [C:\Users\Divya\AppData\Roaming\gcloud\logs\2018.01.11\17.15.05.217000.log].
    
    2018-01-11 17:18:57,487 INFO     root            Uploading [c:\users\divya\appdata\local\temp\tmpoz4cq2\src.tgz] to [us.gcr.io/permission-varal/appengine/default.20180111t171516:latest]
    2018-01-11 17:34:02,029 DEBUG    root            Using runtime builder root [gs://runtime-builders/]
    2018-01-11 17:34:02,029 DEBUG    root            Loading runtimes manifest from [gs://runtime-builders/runtimes.yaml]
    2018-01-11 17:34:02,039 INFO     root            Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x000000000622A860>]
    2018-01-11 17:34:02,983 DEBUG    root            Resolved runtime [php] as build configuration [gs://runtime-builders/php-default-builder-20180109142549.yaml]
    2018-01-11 17:34:02,984 INFO     root            Using runtime builder [gs://runtime-builders/php-default-builder-20180109142549.yaml]
    2018-01-11 17:34:03,140 INFO     root            Reading [<googlecloudsdk.api_lib.storage.storage_util.ObjectReference object at 0x0000000007564F98>]
    2018-01-11 17:34:06,464 INFO     ___FILE_ONLY___ Started cloud build [bcf17e78-6356-4a68-9baf-dec6cb0d265b].
    
    2018-01-11 17:34:06,484 DEBUG    root            GCS logfile url is https://www.googleapis.com/storage/v1/b/staging.permission-varal.appspot.com/o/log-bcf17e78-6356-4a68-9baf-dec6cb0d265b.txt?alt=media
    2018-01-11 17:34:06,484 INFO     ___FILE_ONLY___ To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/bcf17e78-6356-4a68-9baf-dec6cb0d265b?project=permission-varal
    
    2018-01-11 17:34:07,753 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:09,553 DEBUG    root            Reading GCS logfile: 404 (no log yet; keep polling)
    2018-01-11 17:34:10,867 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:12,200 DEBUG    root            Reading GCS logfile: 404 (no log yet; keep polling)
    2018-01-11 17:34:13,448 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:14,769 DEBUG    root            Reading GCS logfile: 404 (no log yet; keep polling)
    2018-01-11 17:34:16,022 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:17,513 DEBUG    root            Reading GCS logfile: 404 (no log yet; keep polling)
    2018-01-11 17:34:18,765 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:20,092 DEBUG    root            Reading GCS logfile: 404 (no log yet; keep polling)
    2018-01-11 17:34:21,397 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:22,782 DEBUG    root            Reading GCS logfile: 404 (no log yet; keep polling)
    2018-01-11 17:34:24,046 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:26,142 DEBUG    root            Reading GCS logfile: 206 (read 219 bytes)
    2018-01-11 17:34:26,194 INFO     ___FILE_ONLY___ ------------------------------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------------------------------
    
    2018-01-11 17:34:26,194 INFO     ___FILE_ONLY___ starting build "bcf17e78-6356-4a68-9baf-dec6cb0d265b"
    
    FETCHSOURCE
    Fetching storage object: gs://staging.permission-varal.appspot.com/us.gcr.io/permission-varal/appengine/default.20180111t171516:latest#1515672240520217
    
    2018-01-11 17:34:26,572 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:28,384 DEBUG    root            Reading GCS logfile: 206 (read 383 bytes)
    2018-01-11 17:34:28,384 INFO     ___FILE_ONLY___ Copying gs://staging.permission-varal.appspot.com/us.gcr.io/permission-varal/appengine/default.20180111t171516:latest#1515672240520217...
    / [0 files][    0.0 B/ 21.4 MiB]                                                
    / [1 files][ 21.4 MiB/ 21.4 MiB]                                                
    
    Operation completed over 1 objects/21.4 MiB.                                     
    
    2018-01-11 17:34:29,625 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] not complete. Waiting 1s.
    2018-01-11 17:34:31,621 DEBUG    root            Reading GCS logfile: 206 (read 2108 bytes)
    2018-01-11 17:34:31,621 INFO     ___FILE_ONLY___ BUILD
    Starting Step #0
    Step #0: Pulling image: gcr.io/gcp-runtimes/php/gen-dockerfile@sha256:edf788ffa9988eaca2652d97da11fbcba70e6a47517a5e58234d67bfabb3d2a7
    Step #0: sha256:edf788ffa9988eaca2652d97da11fbcba70e6a47517a5e58234d67bfabb3d2a7: Pulling from gcp-runtimes/php/gen-dockerfile
    Step #0: Digest: sha256:edf788ffa9988eaca2652d97da11fbcba70e6a47517a5e58234d67bfabb3d2a7
    Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/php/gen-dockerfile@sha256:edf788ffa9988eaca2652d97da11fbcba70e6a47517a5e58234d67bfabb3d2a7
    Step #0: + php /builder/create_dockerfile.php create --php72-image gcr.io/google-appengine/php72@sha256:7377baa6d86fce81a07799c0455617af18ea496483b668b8d7d8c129dfcef4f7 --php71-image gcr.io/google-appengine/php71@sha256:a1dc44d2dd59c4114f3e83f1acf6cccc19642aad970caf69f6424dbe93753485 --php70-image gcr.io/google-appengine/php70@sha256:cfe95f613eaa9790a626d5cc8d05c3ccc4aa3aa5d35d5147b131c6a210117b2a --php56-image gcr.io/google-appengine/php56@sha256:58d815fad2931c1029251dd4aebc78e0e4ff610ac1efe3f58da73f71dde7040d
    Step #0: 
    Step #0: There is no PHP runtime version specified in composer.json, or
    Step #0: we don't support the version you specified. Google App Engine
    Step #0: uses the latest 7.2.x version.
    Step #0: We recommend pinning your PHP version by running:
    Step #0: 
    Step #0: composer require php 7.2.* (replace it with your desired minor version)
    Step #0: 
    Step #0: Using PHP version 7.2.x...
    Step #0: 
    Step #0: 
    Step #0: In GenFilesCommand.php line 277:
    Step #0:                                                                             
    Step #0:   You have to set document_root in the runtime_config section in app.yaml.  
    Step #0:                                                                             
    Step #0: 
    Step #0: create [--php72-image PHP72-IMAGE] [--php71-image PHP71-IMAGE] [--php70-image PHP70-IMAGE] [--php56-image PHP56-IMAGE] [-w|--workspace WORKSPACE]
    Step #0: 
    Finished Step #0
    ERROR
    ERROR: build step 0 "gcr.io/gcp-runtimes/php/gen-dockerfile@sha256:edf788ffa9988eaca2652d97da11fbcba70e6a47517a5e58234d67bfabb3d2a7" failed: exit status 1
    
    2018-01-11 17:34:32,987 DEBUG    root            Operation [operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi] complete. Result: {
        "metadata": {
            "@type": "type.googleapis.com/google.devtools.cloudbuild.v1.BuildOperationMetadata", 
            "build": {
                "finishTime": "2018-01-11T12:04:28.797248166Z", 
                "status": "FAILURE", 
                "timeout": "600s", 
                "startTime": "2018-01-11T12:04:05.278975440Z", 
                "logsBucket": "staging.permission-varal.appspot.com", 
                "results": {
                    "buildStepImages": [
                        "", 
                        ""
                    ]
                }, 
                "id": "bcf17e78-6356-4a68-9baf-dec6cb0d265b", 
                "timing": {
                    "FETCHSOURCE": {
                        "endTime": "2018-01-11T12:04:26.805854103Z", 
                        "startTime": "2018-01-11T12:04:22.656280394Z"
                    }, 
                    "BUILD": {
                        "endTime": "2018-01-11T12:04:28.275430314Z", 
                        "startTime": "2018-01-11T12:04:26.821453395Z"
                    }
                }, 
                "source": {
                    "storageSource": {
                        "object": "us.gcr.io/permission-varal/appengine/default.20180111t171516:latest", 
                        "bucket": "staging.permission-varal.appspot.com"
                    }
                }, 
                "options": {
                    "substitutionOption": "ALLOW_LOOSE"
                }, 
                "steps": [
                    {
                        "timing": {
                            "endTime": "2018-01-11T12:04:28.239822233Z", 
                            "startTime": "2018-01-11T12:04:26.821497421Z"
                        }, 
                        "args": [
                            "--php72-image", 
                            "gcr.io/google-appengine/php72@sha256:7377baa6d86fce81a07799c0455617af18ea496483b668b8d7d8c129dfcef4f7", 
                            "--php71-image", 
                            "gcr.io/google-appengine/php71@sha256:a1dc44d2dd59c4114f3e83f1acf6cccc19642aad970caf69f6424dbe93753485", 
                            "--php70-image", 
                            "gcr.io/google-appengine/php70@sha256:cfe95f613eaa9790a626d5cc8d05c3ccc4aa3aa5d35d5147b131c6a210117b2a", 
                            "--php56-image", 
                            "gcr.io/google-appengine/php56@sha256:58d815fad2931c1029251dd4aebc78e0e4ff610ac1efe3f58da73f71dde7040d"
                        ], 
                        "name": "gcr.io/gcp-runtimes/php/gen-dockerfile@sha256:edf788ffa9988eaca2652d97da11fbcba70e6a47517a5e58234d67bfabb3d2a7", 
                        "env": [
                            "GAE_APPLICATION_YAML_PATH=app.yaml"
                        ]
                    }, 
                    {
                        "args": [
                            "build", 
                            "-t", 
                            "us.gcr.io/permission-varal/appengine/default.20180111t171516:latest", 
                            "--network=cloudbuild", 
                            "."
                        ], 
                        "name": "gcr.io/cloud-builders/docker@sha256:bea5906142dbb335666c3512d65f2372553d2d93df018f86f69368c45d4205a7", 
                        "env": [
                            "GAE_APPLICATION_YAML_PATH=app.yaml"
                        ]
                    }
                ], 
                "sourceProvenance": {
                    "resolvedStorageSource": {
                        "generation": "1515672240520217", 
                        "object": "us.gcr.io/permission-varal/appengine/default.20180111t171516:latest", 
                        "bucket": "staging.permission-varal.appspot.com"
                    }, 
                    "fileHashes": {
                        "gs://staging.permission-varal.appspot.com/us.gcr.io/permission-varal/appengine/default.20180111t171516:latest#1515672240520217": {
                            "fileHash": [
                                {
                                    "type": "MD5", 
                                    "value": "6EqPrvIQES0E59lUklXmDA=="
                                }
                            ]
                        }
                    }
                }, 
                "projectId": "permission-varal", 
                "images": [
                    "us.gcr.io/permission-varal/appengine/default.20180111t171516:latest"
                ], 
                "substitutions": {
                    "_GAE_APPLICATION_YAML_PATH": "app.yaml", 
                    "_OUTPUT_IMAGE": "us.gcr.io/permission-varal/appengine/default.20180111t171516:latest"
                }, 
                "createTime": "2018-01-11T12:04:04.440340699Z", 
                "logUrl": "https://console.cloud.google.com/gcr/builds/bcf17e78-6356-4a68-9baf-dec6cb0d265b?project=permission-varal"
            }
        }, 
        "done": true, 
        "name": "operations/build/permission-varal/YmNmMTdlNzgtNjM1Ni00YTY4LTliYWYtZGVjNmNiMGQyNjVi", 
        "error": {
            "message": "Build failed; check build logs for details", 
            "code": 2
        }
    }
    2018-01-11 17:34:33,325 DEBUG    root            Reading GCS logfile: 416 (no new content; keep polling)
    2018-01-11 17:34:33,326 INFO     ___FILE_ONLY___ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    2018-01-11 17:34:33,368 DEBUG    root            (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/bcf17e78-6356-4a68-9baf-dec6cb0d265b?project=permission-varal Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
    Traceback (most recent call last):
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 791, in Execute
        resources = calliope_command.Run(cli=self, args=args)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 756, in Run
        resources = command_instance.Run(args)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\surface\app\deploy.py", line 65, in Run
        parallel_build=False)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\app\deploy_util.py", line 587, in RunDeploy
        flex_image_build_option=flex_image_build_option)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\app\deploy_util.py", line 377, in Deploy
        flex_image_build_option)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\app\deploy_util.py", line 275, in _PossiblyBuildAndPush
        self.deploy_options.parallel_build)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\deploy_command_util.py", line 442, in BuildAndPushDockerImage
        return _SubmitBuild(build, image, project, parallel_build)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\app\deploy_command_util.py", line 474, in _SubmitBuild
        build, project=project)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\cloudbuild\build.py", line 199, in ExecuteCloudBuild
        self.WaitAndStreamLogs(build_op)
      File "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\api_lib\cloudbuild\build.py", line 244, in WaitAndStreamLogs
        + message)
    BuildFailedError: Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/bcf17e78-6356-4a68-9baf-dec6cb0d265b?project=permission-varal Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
    2018-01-11 17:34:33,664 ERROR    root            (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/bcf17e78-6356-4a68-9baf-dec6cb0d265b?project=permission-varal Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details
    2018-01-11 17:34:34,236 DEBUG    root            Metrics reporting process started...
    &#13;
    &#13;
    &#13;

    app.XAML FILE

    &#13;
    &#13;
    env: flex
    runtime: php
    
    handlers:
    - url: /.*
      script: loginpage.php
      
    - url: /stylesheets
      static_dir: stylesheets
    
    - url: /(.*\.(gif|png|jpg))$
      static_files: static/\1
      upload: static/.*\.(gif|png|jpg)$
    
    - url: /.*
      script: not_found.php
    &#13;
    &#13;
    &#13;

    下面我分享了我的运行屏幕和app.yaml配置设置以及我的项目根详细信息。请帮助我部署项目。

    enter image description here

2 个答案:

答案 0 :(得分:0)

我从这里开始:

Step #0: In GenFilesCommand.php line 277:
Step #0:        
Step #0:   You have to set document_root in the runtime_config section in app.yaml.

Hello World code review中的示例相比,我注意到您在app.yaml文件中修改了与此类似的部分,该部分与引用的日志片段相关:

runtime_config:
  document_root: web

答案 1 :(得分:0)

您应该使用runtime: custom并创建一个Dockerfile,因为您的PHP版本可能是默认的默认应用引擎PHP版本。