I'm having some weird problem with Laravel 8.
I installed the framework and started working with it, but when I try to edit / delete some controller, my Ubuntu asks for a password.
Another problem. My controller displays records on a page with paginate(15) pagination, but instead of the usual numbers, I get the Previous & Next direction, and when I try to change something in the html template, I get an error file_put_contents(/var/www/storage/framework/views/c6d615eb91fe3a0edd449165e94d034703bbb84d.php): failed to open stream: Permission denied and this problem can only be cured by clearing the cache, but this should not be the case.
Error #1: Your user does not have write permissions for those files/directories. Did you use sudo while installing or copying anything? Do you have these files outside of your home directory? (/home/username/)
Error #2: Your webserver (nginx, apache, etc.) probably does not have access to the application's /storage/ directory.
SSH into the server.
Navigate to the projects root folder.
Run the following commands to make the directories writable:
sudo chmod -R gu+w storage/
sudo chmod -R guo+w storage/
sudo chmod -R gu+w bootstrap/cache/
sudo chmod -R guo+w bootstrap/cache/
I have a project work in laravel (Mac) but I have a problem:
file_put_content fail () Permission denied.
I try below command
cd /path to htdocs
sudo chgrp -R _www storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
but it's not working
anyone know how to solve this problem. I use XAMPP, is that possible to set my XAMPP htdocs folder permission read&write, so I don't need to worry about this anymore
It's coming from cache. Delete bootstrap > cache > config.php file.
Then use php artisan config:cache.
you need to provide write access to your storage folder too.
try running :
sudo chmod -R 777 storage bootstrap
It will provide read & write and execute permissions to both storage and bootstap folder.
Thanks in advance for the helpers. I am configuring a centOS 7 VPS. I put my laravel 5.5 site there. I got the permissions issue with laravel log file. I changed the permissions to 777 recursively. But the issue still remains.
Can anybody help?
Thank you
chown -R www-data:www-data /var/www/html/laravel chmod -R 755
/var/www/html/laravel/storage
I just updated ubuntu packages and composer update from inside my ssh terminal on Forge
Now when I try to login I get TokenMismatchException in VerifyCsrfToken.php (line 68)
I have tried
deleted browsers cookies and application data
php artisan clear:cache
composer dump-autoload
Deleted composer.lock on both sides, updated from homestead and git push to server
php artisan clear-compiled
Restarted Nginx, Server
I am running out of ideas now. What can I do to fix this??
Thanks
After discussion, it was a folder permissions issues.
chmod 777 -R storage
OP must be careful with this as it opens up the server.
More appropriate for production would be the following:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
chmod 777 -R storage was enough to enable log in, but it brought other issues. Users could not post images for example.
This is eventually what worked for me -
ssh
Check if forge is set as the user $ ps -aux | grep "php"
if you get www-data instead of forge, you might have the same problem as me and need to set forge as the user instead of www-data
$ sudo chown -R forge:www-data /home/forge/mysite.com
$ sudo chmod -R 770 /home/forge/mysite.com
Everything works as expected for me again
Back to pretending like I know what I'm doing!! :D
I've just git clone a repository of mine containing a Laravel 5.1 project. I've gone through the normal steps to get it up and running (setup the webserver, db, etc). I've now gone to the web address I configured and i'm getting the following error message:
ErrorException in compiled.php line 6648:
file_put_contents(/3c7922efc24ab13620cd0f35b1fdaa61): failed to open stream: Permission denied
Any idea's what folder it's trying to access?
I solved the problem with this solution, clarifying that if you have Windows, you apply lines 1 and 3 and it works the same.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
To solve this problem I needed to create a few folder's that were missing from my install. You require the following folders to be readable and writable by your www user:
/storage
/storage/cache
/storage/framework
/storage/framework/sessions
/storage/framework/views
/storage/framework/cache
/storage/logs
Also, set the folder permissions to 775. From the root directory run the command: sudo chmod -R 755 storage
If nothing help you and if you work on windows with docker it can be the issue that wrong symlink you have, you can try:
ln -s /var/www/storage/app/public /var/www/public/storage
And after that:
chown -R $USER:www-data storage
chmod -R 777 storage
on docker bash.
If you're using ubuntu, most likely you have to give permissions to that folder storage
cd into the project and
use the command -> sudo chmod 755 storage/*
I had similar problem in my localhost and the problem was that I was trying to upload a file larger than upload_max_filesize in my php.ini file .
just updating this to greater value and restart my server solved the problem ,, if you having similar problem this might be the case
If you are on a Linux distribution with SELinux enabled, here is what you need to do:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/my-app/storage
sudo chown -R nginx /var/www/html/my-app/storage
sudo chmod -R u+w /var/www/html/my-app/storage
This should set the proper context for the storage directory, allowing the web server to write to it.
I had this problem lately with my tests, and resolved it through: composer dump-autoload
This is how I solve a similar issue since I don't have access to the terminal to run sudo chown -R www-data:www-data /thedirectory
in
config/filesystem.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Then in my uploader controller
use Illuminate\Support\Facades\Storage;
$file_path= Storage::path('public/importable');
if (!is_dir($file_path)) {mkdir( $file_path,0775, true);}
This is a permission issue. I used few hours to resolve this problem. I found only 3 lines to give permissions. So first go to root folder f your Laravel application and run these 3 lines.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
For me it was because the single file was owned by root...written at some point when I setup the files, and the app couldn't read it. Solution could be to change ownership, get rid of it, etc.
For me solution was to change folder owner of laravel project. Ensure that is your own user and not root:www-data.
sudo chown -R username:group directory
Run the following command in the directory that is being triggered to check the permissions:
ls -lah
Then if there was any issue you can correct it with:
sudo chown -R username:group directory