3
votes

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

The code is app.yaml file in root folder of my laravel app.

Copyright 2015 Google Inc. All Rights Reserved.

runtime: php72

api_version: 1

threadsafe: true

runtime_config: document_root: public

handlers: - url: /favicon.ico static_files: public/favicon.ico upload: public/favicon.ico

  • url: .* script: auto

env_variables: # Uncomment the following to enable debug mode.

APP_DEBUG: 0

APP_LOG: errorlog APP_KEY: base64:nzd12xL4YtD3fIKYYRc/NGIfA+phk39fGJrvq11UBug= APP_LOG_LEVEL: debug STORAGE_DIR: /tmp

DB_HOST: '' DB_USERNAME: '' DB_PASSWORD: '' DB_DATABASE: ''

CACHE_DRIVER: memcache SESSION_DRIVER: memcache MAIL_DRIVER: 'mail' LOG_DRIVER: 'syslog'

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

enter image description here

1
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run. If you are using the Homestead virtual machine, these permissions should already be set.aynber

1 Answers

0
votes

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

Briefly -

Step 1, in app.yaml you need to add:

APP_STORAGE: /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]