问题描述
laravel应用程序在我的本地环境中运行良好.但是,当我使用命令gcloud app deploy
将其上传到Google App Engine时.然后给我写日志的错误.
The laravel application working well in my local.But when I upload it to Google App Engine, using command gcloud app deploy
. Then it give me error writing logs.
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文件.
The code is app.yaml file in root folder of my laravel app.
运行时:php72
runtime_config: document_root:公开
runtime_config: document_root: public
处理程序:-网址:/favicon.ico 静态文件:public/favicon.ico 上传:public/favicon.ico
handlers:- url: /favicon.ico static_files: public/favicon.ico upload: public/favicon.ico
- 网址:.*脚本:自动
- url: .*script: auto
env_variables: #取消注释以下内容以启用调试模式.
env_variables: # Uncomment the following to enable debug mode.
APP_LOG:错误日志 APP_KEY:base64:nzd12xL4YtD3fIKYYRc/NGIfA + phk39fGJrvq11UBug = APP_LOG_LEVEL:调试 STORAGE_DIR:/tmp
APP_LOG: errorlog APP_KEY: base64:nzd12xL4YtD3fIKYYRc/NGIfA+phk39fGJrvq11UBug= APP_LOG_LEVEL: debug STORAGE_DIR: /tmp
DB_HOST:" DB_USERNAME:" DB_PASSWORD: DB_DATABASE:"
DB_HOST: '' DB_USERNAME: '' DB_PASSWORD: '' DB_DATABASE: ''
CACHE_DRIVER:内存缓存 SESSION_DRIVER:内存缓存 MAIL_DRIVER:邮件" LOG_DRIVER:"syslog"
CACHE_DRIVER: memcache SESSION_DRIVER: memcache MAIL_DRIVER: 'mail' LOG_DRIVER: 'syslog'
STORAGE_PATH:'gs://#default#/laravel/storage'
STORAGE_PATH: 'gs://#default#/laravel/storage'
推荐答案
您需要按照以下说明中的步骤(1)和(3)重写Laravel在哪里存储内容:
You need to rewrite where Laravel stores things as per step (1) and (3) in these instructions:
https://cloud.google.com/community /tutorials/run-laravel-on-appengine-standard
简短-
步骤1,在app.yaml中,您需要添加:
Step 1, in app.yaml you need to add:
APP_STORAGE: /tmp
然后在步骤3中,让Laravel使用它.通过在return语句之前添加以下代码块来修改bootstrap/app.php.这将使您可以将存储路径设置为/tmp以便在生产中进行缓存.
Then in Step 3 you make Laravel use this. Modify bootstrap/app.php by adding the following block of code before the return statement. This will allow you to set the storage path to /tmp for caching in production.
# [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]
这篇关于我的Laravel应用程序在Google Cloud上有问题.流或文件"/srv/storage/logs/laravel.log"被指定为"/srv/storage/logs/laravel.log".不能打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!