Reputation: 61
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"
Upvotes: 1
Views: 7927
Reputation: 2295
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.
Upvotes: 0
Reputation: 15072
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).
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'
Upvotes: 1
Reputation: 15175
run this command in terminal used chmod
sudo chmod -R 0777 /srv/storage/logs/
Upvotes: 0