1

We are trying to connect with laravel and app engine but we are facing issue of storage permission. Is there any way to change storage path to app engine storage path. So we could solve permission denied issue.

As app engine does not have read and write permission.

Here i have attached my app yaml file details

runtime: php72

runtime_config:

document_root: public

env_variables:

  #Put production environment variables here.
  #LOG_CHANNEL: stackdriver
  APP_NAME: eProfit
  #APP_ENV: local
  #APP_DEBUG : true # or false 
  APP_LOG: errorlog
  APP_KEY: base64:3KcvHI2FZIT5n0BeiXynkjfvI9O7AzdOpeYhD4W4WgQ=
  #STORAGE_DIR: /tmp
  #APP_STORAGE : /tmp
  CACHE_DRIVER: file
  SESSION_DRIVER: file

## Set these environment variables according to your CloudSQL configuration.

  DB_HOST: localhost
  DB_DATABASE: databasename
  DB_USERNAME: root
  DB_PASSWORD: password
  DB_SOCKET: DB_SOCKEt

beta_settings:

cloud_sql_instances: "eprofit-3:us-central1:eprofit-3"
mebius99
  • 2,495
  • 1
  • 5
  • 9
Alex Brend
  • 61
  • 1
  • 8
  • Did you solve this issue? I have same one... – MrViSiOn Mar 02 '19 at 14:37
  • Don't ever use 777 - that is just avoiding the real issue... I've come to an issue with deployed app that was actually running in `/var/www/myapp/` but logs were WRONGLY trying to be placed in `/srv/...` instead of `/var/...` which seems to be your case too :) – jave.web Sep 19 '19 at 22:00
  • However it may be permission issue - in that case you should set-up your permissions correctly - maximum 775 - and make sure what runs app (typically webserver like apache) is running it as a user that is in the same group as it is the owner of the files (if it is not owner of the files itself). – jave.web Sep 20 '19 at 20:24
  • Duplicate of https://stackoverflow.com/questions/54111512/my-laravel-application-has-a-problem-on-google-cloud-the-stream-or-file-srv-s/60127396#60127396 or vice-versa – sifriday Feb 08 '20 at 13:49

5 Answers5

1

TL;DR - purposely different storage location => GOTO Case 2

Case 1: You want storage/logs to be placed in /srv/...

Laravel storage directory is commonly placed in the app root - typically something like /var/www/projectname/storage
However you of course could decide, you want the storage (and logs) to send purposely elsewhere (in your case /srv/storage / /srv/storage/logs
=> if this is unwanted/by accident or you wish to store it elsewhere - see Case2

Regardless of where you have your storage - system user that runs the app (typically webserver like apache) should have permissions to write to the storage directory and files - how to do that is a different question, already answered here - How to set up file permissions for Laravel?.
Basically you make sure the system-user running the app (e.g. www-data) has read&write permissions of the storage directory and files as an owner or as a group (where system-user and owner are in) (maximum 775).

NEVER GIVE 777 PERMISSIONS (SECURITY ISSUES)

Case 2: Purposedly change storage/logs location

In some cases you want to place storage/logs elsewhere, that is quite easily doable in bootstrap/app.php with this code:

$app->useStoragePath("/ABSOLUTE/PATH/TO/STORAGE/NOTRAILINGSLASH")

I however don't recommend doing this with plain string - you should use .env file(s) to define storage path in each environment and here dynamically get it if available with
env('YOUR_STORAGE_PATH_ENV_VARIABLE)

So you end up with something like this in bootstrap/app.php file:

$envStoragePath = env('YOUR_STORAGE_PATH_ENV_VARIABLE');
if (!empty($envStoragePath)) {
   $app->useStoragePath($envStoragePath);
}
// condition can be shorten to:
// empty($envStoragePath)) ?: $app->useStoragePath($envStoragePath);

And with something like this in .env file(s):

YOUR_STORAGE_PATH_ENV_VARIABLE = '/YOUR/ENVIRONMENT/SPECIFIC/STORAGE/PATH'
Community
  • 1
  • 1
jave.web
  • 13,880
  • 12
  • 91
  • 125
0

give permission to /storage folder.

chmod 777 -R /storage
0

run this command in terminal used chmod

sudo chmod -R 0777 /srv/storage/logs/
Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
0

Please run below command

sudo chmod -R 777 /srv/storage/
0

Did you solved this Google App Engine problem? I think you can't set the permissions to the app engine, because it is all write protected.

Mondy
  • 2,055
  • 4
  • 19
  • 29