My problem is that when I use caching in Laravel with file driver, I occassionally lose permissions to the cache file. Permissions are set properly, parent folder does not lose any permissions, only the specific cache file. After restarting the machine, permissions are back and I can delete the file manually.
The "permission" error is like:
file_put_contents(C:\inetpub\wwwroot\office_map_dev\storage\framework/cache/data/ca/0d/ca0d727b27eefcb8763203d9ad28f5a5eb29a85e): Failed to open stream: Permission denied
Related
I've set all the permissions up and everything has been working perfectly for about 2 years until today when I force cleared the cache using php artisan cache:clear
Now, when the cache gets created in /storage/framework/cache, it works fine and all the permissions are set correctly except for the occasional file.
I could have thousands of cache files in there, all with the correct permissions (www-data as user and group). . but then randomly one file will generate using the wrong permissions which ends up with this error.
file_put_contents(/.../.../storage/framework/cache/data/52/cf/52cf02760233b9fc625602f52fd0748a51ac772a): failed to open stream: Permission denied
When I navigate to the file, the permissions are set to 744 and the user/group is set to root:root. Every other cache file is set to 774 and www-data:www-data.
I can fix it temporarily by running sudo chown -R www-data:www-data storage which sets the folders to the correct group and user but then the error appears again after about 15 minute once another file generates with the incorrect permissions.
What can be causing this?
I am using Laravel and it works well. After updating one blade file on my local pc and deployed it with git, Laravel can't open that particular blade anymore.
file_put_contents(/var/www/vhosts/***/httpdocs/memberportal/storage/framework/views/8274d2f145c8a134eb15ccbb69c2df396814d64e.php):
failed to open stream: Permission denied (View: /var/www/vhosts/***/httpdocs/memberportal/resources/views/emails/newsletter/2019-04-2/translations/advertise/en.blade.php)
at /var/www/vhosts/***/httpdocs/memberportal/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122,
ErrorException(code: 0): file_put_contents(/var/www/vhosts/***/httpdocs/memberportal/storage/framework/views/8274d2f145c8a134eb15ccbb69c2df396814d64e.php):
failed to open stream: Permission denied at /var/www/vhosts/***/httpdocs/memberportal/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122)
The folder permission and owner of the storage folder and en.blade.php are correct. However, I noticed that the owner/group of the files in the cache are different.
All caches files with owner root:root are not accessible. Any ideas why Laravel changes the ownership of cache files on my production server, when deploying with git? The storage files are ignored by git, so I do not understand how this happens.
Any advice?
Did clean installation of ddev on my Mac.
Set up Drupal 8 project and have problems with file permissions on sites/default/files folder. For some reason it resets the permissions I set (chmod -R a+w) and web server can't write to this folder afterwards.
Files are owned by uid_1000 gid_50.
Example of the message
Warning: file_put_contents(sites/default/files/php/twig/5c1ad9b345ce5_status-messages.html.twig_3IhisVoQLOYIb64NBegMDuHJs/.htaccess): failed to open stream: Permission denied in Drupal\Component\PhpStorage\FileStorage->ensureDirectory() (line 123 of core/lib/Drupal/Component/PhpStorage/FileStorage.php).
I have a Joomla 1.5.20 site and I am not able to upload & update any file in it. The website is running on a Windows Webserver.
Warning: file_put_contents(D:\inetpub\vhosts\hidden\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc) [function.file-put-contents]: failed to open stream: Permission denied in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 8666
Warning: D:\inetpub\vhosts\hidden.tld\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc is not writeable in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 1779
Warning: file_put_contents(D:\inetpub\vhosts\hidden.tld\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc) [function.file-put-contents]: failed to open stream: Permission denied in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 8666
Warning: D:\inetpub\vhosts\hidden.tld\httpdocs\v1\administrator\cache/da4f9e501a6359708d714f016ef2d500.spc is not writeable in D:\inetpub\vhosts\hidden.tld\httpdocs\v1\libraries\simplepie\simplepie.php on line 1779
I have tried deleting and recreating cache folder. Since it is a windows webserver I don't it a permission issue. Please advise me on how to fix it. Thanks!
You need to check your folder permissions:
Login to Administrator panel
Select Help > System info from top menu
Select tab Directory Permissions, all folders listed here need to have 'Writable' permissions.
If any of those folders are Unwritable, login to your server with ftp client, or cPanel, and change folder's CHMOD permissions to 755
I have a client who is running a user management script. The host provider had blocked allow_url_fopen but is using suPHP so we created a local copy of php.ini with allow_url_fopen set to "on".
The only problem now is that you can no longer login to using the script - it says 'success logging you in' - then logs you right out (because the sessions are either not getting created or are in the wrong place - excuse my lack server knowledge).
Here are the settings in the local php.ini
upload_tmp_dir = "/home/aspac124/public_html/tmp"
register_globals = On
memory_limit = 256M
session.save_path = "/home/aspac124/public_html/tmp"
safe_mode = off
upload_max_filesize = 32M
allow_url_fopen = On
zend_extension = "/usr/local/IonCube/ioncube_loader_lin_5.3.so"
I'm not sure why the hosting provider turned register_globals on for the client. But is that the correct place for the session.save_path? I've checked and the folder exists and I also set it to 777 just to make sure but no happiness.
Another client using the same system had a similar issue and told me he changed the tmp/ folder to his home directory and everything was fine.
I've tried to put the save path as just /tmp, /home/aspac124/tmp and nothing happens - just get logged out as normal. If I make up a path then I get a "No such file or directory" error.
When I put it as "/home/tmp" I get the following message
Warning: session_start() [function.session-start]: open(/home/tmp/sess_4417d180e599b5f12fc34a28f5467d21, O_RDWR) failed: Permission denied (13) in /home/aspac124/public_html/domainnamehere.com/includes/lightwork_session.php on line 45
What does this mean, is the home/tmp the correct place for this and if so what should I do - should the folder permissions be changed?
edit: I don't have access to folders outside the domain root so cannot change the file permissions - have to wait for the client but would like as much info before then.
Thanks in advance
EDIT: Just for anyone reading this. Please make sure your local php.ini file settings are applied to any sub folder that may require it. I was making ajax requests to a file in a sub folder to the root and this was the issue.
You should place your session and upload directories outside of the document root otherwise these will be accessible by anyone and can result in remote script injection, session hijacking etc.
You should perhaps create a tmp directory as /home/aspac124/tmp and set the permissions so Apache can write to this directory. Perhaps set the chmod to 0760.