gpt4 book ai didi

php - 我的 Laravel 应用程序在 Google Cloud 上有问题。无法打开流或文件 "/srv/storage/logs/laravel.log"

转载 作者:行者123 更新时间:2023-12-05 07:27:01 24 4
gpt4 key购买 nike

laravel 应用程序在我的本地运行良好。但是当我使用命令 gcloud app deploy 将它上传到 Google App Engine 时。然后它给我错误写入日志。

UnexpectedValueException
The stream or file "/srv/storage/logs/laravel.log" could not be opened: failed to open stream: Read-only file system

代码是我的 laravel 应用程序根文件夹中的 app.yaml 文件。

2015 Google Inc 版权所有。保留所有权利。

运行时:php72

api_version: 1

线程安全:真

运行时配置: 文档根目录:公共(public)

处理程序:- 网址:/favicon.ico 静态文件:public/favicon.ico 上传:public/favicon.ico

  • 网址:.*脚本:自动

环境变量: # 取消注释以下内容以启用 Debug模式。

APP_DEBUG:0

APP_LOG:错误日志 APP_KEY: base64:nzd12xL4YtD3fIKYYRc/NGIfA+phk39fGJrvq11UBug= APP_LOG_LEVEL:调试 存储目录:/tmp

数据库主机:'' DB_USERNAME:'' 数据库密码:'' DB_DATABASE: ''

CACHE_DRIVER:内存缓存 SESSION_DRIVER:内存缓存 MAIL_DRIVER: '邮件' LOG_DRIVER: '系统日志'

STORAGE_PATH: 'gs://#default#/laravel/storage'

enter image description here

最佳答案

您需要按照这些说明中的步骤 (1) 和 (3) 重写 Laravel 存储内容的位置:

https://cloud.google.com/community/tutorials/run-laravel-on-appengine-standard

简述-

第一步,在app.yaml中需要添加:

APP_STORAGE: /tmp

然后在第 3 步中让 Laravel 使用它。通过在 return 语句之前添加以下代码块来修改 bootstrap/app.php。这将允许您将存储路径设置为/tmp,以便在生产中进行缓存。

# [START] Add the following block to `bootstrap/app.php`
/*
|--------------------------------------------------------------------------
| Set Storage Path
|--------------------------------------------------------------------------
|
| This script allows you to override the default storage location used by
| the application. You may set the APP_STORAGE environment variable
| in your .env file, if not set the default location will be used
|
*/
$app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));
# [END]

关于php - 我的 Laravel 应用程序在 Google Cloud 上有问题。无法打开流或文件 "/srv/storage/logs/laravel.log",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54111512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com