Google App Engine(GAE)错误:chown:无法访问“ / app / public”:没有这样的文件或目录

时间:2018-10-22 13:31:20

标签: laravel symfony google-app-engine deployment google-cloud-platform

首先获取此错误表格“ gcloud deploy”。项目是Laravel应用。我已经在所有日志和文件中用一些虚拟信息替换了生产信息。

我将一些较旧的帖子改成红色,但出现了同样的问题,但没有回应。 ¿有人遇到同样的问题吗?我已经使用新的laravel 5.7安装进行了测试,并得到相同的错误。我已经删除了整个项目,并创建了一个新的GAE项目。不知道还能尝试什么。另外,我已经对Symfony 4框架项目和相同的问题进行了测试。

$con = 'mysql:host=localhost;dbname=example';
$username = 'example';
$password = 'example';
$pdo = new PDO($con, $username, $password);

$i = !empty($_GET['pass']) ? (int) $_GET['pass'] : 0;

$string = "SELECT * FROM users LIMIT $i,10";
$query = $pdo->prepare("$string");
$query->execute();
// This would not fill memory anymore.
$results = $query->fetchAll();
// Nothing to do, we have finished.
if (!count($results)) {
  return;
}
foreach ($results as $result) {
  // Perform lengthy operation.
  sleep(1);
}

$i++;
// Send request back to process next execution.
$redirect = $_SERVER['DOCUMENT_URI'] . '?pass=' . $i;
header("Location: $redirect");
exit();

我的Laravel项目composer.json

//file: app.yaml

service: api-dev
runtime: php
env: flex

runtime_config:
  document_root: public
  front_controller_file: index.php
  skip_lockdown_document_root: true #<= this does the trick!!??
  #enable_stackdriver_integration: true

# Ensure we skip ".env", which is only for local development
skip_files:
- .env
- .git

env_variables:
  # Put production environment variables here.
  APP_LOG: errorlog
  APP_ENV: local
  APP_DEBUG: true
  APP_KEY: base64:SECRET
  STORAGE_DIR: /tmp
  ## Set these environment variables according to your CloudSQL configuration.
  DB_HOST: localhost
  DB_DATABASE: api_db
  DB_USERNAME: api_user
  DB_PASSWORD: api_pwd
  DB_SOCKET: "/cloudsql/YOUR_INSTANCE_NAME"

beta_settings:
  # for Cloud SQL, set this value to the Cloud SQL connection name,
  # e.g. "project:region:cloudsql-instance"
  cloud_sql_instances: "YOUR_INSTANCE_NAME"

这是deploy命令的完整输出: 'gcloud app deploy deploy / dev.yaml --verbosity = debug'

//composer.json

{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "tymon/jwt-auth": "0.5.*",
    "phpoffice/phpexcel": "1.8.x-dev",
    "maatwebsite/excel": "~2.1.0",
    "barryvdh/laravel-dompdf": "0.6.*",
    "vsmoraes/laravel-pdf": "^1.0",
    "laravelcollective/html": "~5.0",
    "barryvdh/laravel-snappy": "^0.3.3",
    "inacho/php-credit-card-validator": "1.*",
    "laravel/envoy": "^1.4"
  },
  "require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~4.0",
    "symfony/css-selector": "2.8.*|3.0.*",
    "symfony/dom-crawler": "2.8.*|3.0.*"
  },
  "autoload": {
    "classmap": [
      "database"
    ],
    "psr-4": {
      "App\\": "app/"
    }
  },
  "autoload-dev": {
    "classmap": [
      "tests/TestCase.php"
    ]
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "php artisan key:generate"
    ],
    "post-install-cmd": [
      "chmod -R 755 bootstrap\\\/cache",
      "php artisan cache:clear"
    ],
    "pre-update-cmd": [
      "php artisan clear-compiled"
    ],
    "post-update-cmd": [
      "php artisan optimize"
    ]
  },
  "config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}

2 个答案:

答案 0 :(得分:1)

我刚刚发现,通过在“ runtime_config”节点中添加“ skip_lockdown_document_root:true”,它不再失败。有谁能为假人解释这个动作是什么?我没有找到明确的解释。我想知道使用此“ skip_locakdown_document_root”选项的内幕是怎么回事。我可以猜测它确实是chmod / chown,但我想确认一下。谢谢

答案 1 :(得分:1)

我遇到了类似的问题,但是碰巧我改变了部署项目的方式,而且路径不再正确。

我使用了提到的“ skip_lockdown_document_root”选项来启动VM,将其SSH并了解问题。 (我的错误是500)