How to access Laravel Folder in Google Cloud - laravel

I received an error on my Laravel App
/app/storage/logs/laravel-2020-02-20.log" could not be opened: failed to open stream: Permission denied
So I google the error, and I discovered it a permission error.
chmod -R 775 storage
chmod -R 775 bootstrap/cache
Apparently, this fixes the error, but anytime I tried to run the command in the cloud console. It keeps saying
No directory found.
Can someone advice me on how to access storage directory.

From the tags, I can tell it is GAE flex on GCP. Flex gives you SSH access, but it is not advisable to execute read/write operations directly on the Instances as they are preemptive - can be restarted anytime by GCP. So any command you execute will have to be repeated whenever a new instance starts, which will of course defeats the purpose of scalability on GAE flex.
Try this instead:
On the composer.json file in your project directory, add the follow to the scripts:
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"#php artisan optimize",
"chmod -R 755 storage bootstrap\/cache" ]
For more info, check this community link: https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible

Related

My Laravel App on AWS EB always occurs Permission denied Error after Lambda function restarts it

On AWS, I've set CloudWatch events to trigger Lambda functions which stop/restart Elastic Beanstalk environment where my Laravel + docker-compose app sits in. However, after restarting, my Laravel app occurs an Error;
The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
I can fix this error rather easily, by using eb cli. All I have to do is connect to the app, go into a docker container and run the following command;
chgrp -R www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache
Hoevever...do I have to do this every morning!?
Is there a way to avoid Permission denied Error after restarting? Or is there a way to automate the above two commands? If anyone could shed some lights on it, I'd really appreciate it.

Laravel on ElasticBeanstalk 'log file permission denied' error keeps coming up even the permission is set in the .ebextensions config file

I am deploying my Laravel application to the ElasticBeanstalk environment. But I am having issue with laravel.log file permissions.
I deployed my application using "eb deploy" command. After I deployed, I access my application. But it is throwing the following error.
The stream or file "/var/app/current/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
To solve the issue, I ssh into the server and run the following command.
sudo -u root chmod 777 -R /var/app/current/storage/logs
The problem is solved. Now my application is working. But I deploy my application again running "be deploy" command. After the deployment, the issue popped up again. To solve the issue in a consistent way. I tried to run the command in the .ebextensions config file as follow.
container_commands:
01-migrations:
command: "php artisan migrate --force"
02-log-storage-permissions:
command: "sudo -u root chmod -R 777 /var/app/current/storage/logs/"
I could deploy my application. But the issue still persists. It seems like the command is not working. What is wrong with my configuration and how can I fix it?
I believe that this is because container_commands run when your application is in the staging folder. Thus, after you run 02-log-storage-permissions, your /var/app/current will be replaced anyway with the staging folder. So your chmod wont persist.
To rectify the issue, you can try one of the two options:
Use
02-log-storage-permissions:
command: "sudo -u chmod -R 777 ./storage/logs/"
to change the logs in staging folder.
use postdeploy hook to run your script:
after the Elastic Beanstalk platform engine deploys the application and proxy server.

Unable to configure Laravel storage symlink

Tired of searching :-(
Configuration:
AWS (Instance)
Ubuntu 14.04.6 LTS
Laravel 5.8
Project root -> Permission and ownership
Inside project root
php artisan storage:link
project/public
Browser console says:
The complete project is working fine, even I am able to upload as follows.
$request->file('picture')->store('profile_pictures', 'public')
You might want to try this.
cd /var/www/html/yourproject
chmod -R 755 storage
chown -R www-data:www-data storage
Thanks.

xampp ubuntu laravel The stream or file "/storage/logs/laravel log" could not be opened: failed to open stream: Permission denied

installed laravel on my xampp installation on ubuntu. opened it in browser. got the error:
The stream or file /storage/logs/laravel log could not be opened: failed to open stream: Permission denied
how to fix? (i've already found an answer, will post right now)
the problem is that the user under which the apache runs doesn't have access to the folder. in xampp on ubuntu, the user of main apache process is root. but apache workers run under daemon user. the solution is to grant daemon access to the /storage dir. (if you'll only grant to /storage/logs than you'll fix this error, but the same error will occur with sibling dirs. thus the storage itself folder:
sudo chown -R daemon /path-to-your-project/storage
now the daemon user has access to this folder (and you don't but do you need it?
if you have better solutions, please feel free to share them here!
Add to composer.json
"scripts": {
"post-install-cmd": [
"chgrp -R www-data storage bootstrap/cache",
"chmod -R ug+rwx storage bootstrap/cache"
]
}
Then run composer install or update solve your issue

After uploading into cpanel Laravel 5.3 throwing InvalidArgumentException error

After Developing a test App using Laravel 5.3, When I uploaded to the Cpanel it throwing Invalid exception Error. According to error message the App looking for some files from my local PC.Even after clearing all files from Storage\framwork\session it behaves alike previous.
App link: http://autocomplete.bappasarkar.info/
NB: After first time uploading the app threw an error
The only supported ciphers are AES-128-CBC and AES-256-CBC
Then I generate key by the artisan command
"php artisan key:generate"
After generating key when the App uploaded for the second time , it's throwing the current Error.
You have permissions issue, the following commands are for *nix based OS's.
Try
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
You can change the permission through ftp or file manager from Cpanel.

Resources