Laravel 应用程序在我的本地运行良好。
但是当我使用命令将其上传到 Google App Engine 时gcloud app deploy
。然后它给我写日志时出错。
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_版本:1
线程安全:真
运行时配置:
文档根目录:公共
处理程序:
- 网址:/favicon.ico
静态文件:public/favicon.ico
上传:public/favicon.ico
环境变量:
# 取消注释以下内容以启用调试模式。
应用程序调试:0
APP_LOG:错误日志
APP_KEY:base64:nzd12xL4YtD3fIKYYRc/NGIfA+phk39fGJrvq11UBug=
APP_LOG_LEVEL:调试
存储目录:/tmp
数据库主机:''
数据库用户名:''
数据库密码:''
数据库_数据库:''
CACHE_DRIVER:内存缓存
SESSION_DRIVER:内存缓存
MAIL_DRIVER: '邮件'
LOG_DRIVER: '系统日志'
STORAGE_PATH: 'gs://#default#/laravel/storage'
在此输入图像描述 https://i.stack.imgur.com/9C9K1.png
您需要按照以下说明中的步骤 (1) 和 (3) 重写 Laravel 存储内容的位置:
https://cloud.google.com/community/tutorials/run-laravel-on-appengine-standard https://cloud.google.com/community/tutorials/run-laravel-on-appengine-standard
简要地 -
步骤1,在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]
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)