Kohana Logs file writable but permission denied - php

I have checked the install.php and it gives me the green light on the logs file. However, my application gets an error saying
ErrorException [ 2 ]: file_put_contents(/my/app/path/logs/2013/03/04.php): failed to open stream: Permission denied ~ SYSPATH/classes/Kohana/Log/File.php [ 90 ]

I am also faced the same issue,i solved it with help of below comment to make all sub directories writable.
chmod -R 777 cache/ logs/
This may help future referrer.

Even if logs/ directory exists and have proper permissions set, it's subdirectories (like logs/2013/ and logs/2013/03) could have improper permissions, for example due to some file copying or so...
Be sure that all subdirectories allow writting for user/group/other.

Related

The stream or file "D:\Inetpub.....\storage\logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied on Windows

I have a website made with Laravel, I need to upload it to windows server (Plesk Cpanel) i have set the database and everything is good, but when trying to open the website it shows me :
The stream or file "D:\Inetpub.....\storage\logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
no solution found for windows any help, please?
You must change permissions for this file, or for all "storage" dir.
I found this in Google for Plesk - Link for Plesk and for Cpanel - Lunk for CPanel.
You must set 777 or read, write, execute permissions for all groups.
Or read here what permissions you need.
Good luck!
sudo chmod 777 path/to/project/storage/logs/laravel.log

Writing Log File Error file_put_contents(/var/www/html/myproject/ulogs/my-log.log): Failed to open stream: Permission denied

I have inherited a PHP application and need to investigate various issues. I am not a PHP programmer so bear with me.
I wrote a function to log messages to a custom log file.
<?php
function my_logger($log_msg)
{
error_log("USER INFO:::::",0);
error_log(get_current_user());
error_log(exec('whoami'));
file_put_contents('/var/www/html/myproject/ulogs/my-log.log', date('G:i:s') . ">>$ " . $log_msg . "\n", FILE_APPEND);
}
After a lot of 500 errors and no information I discovered that the following line is being written to the error_log.log
PHP Warning:
file_put_contents(/var/www/html/myproject/ulogs/my-log.log): Failed to
open stream: Permission denied in
/var/www/html/myproject/app/lib/log_fns.php on line 11
I have put in a call to get_current_user and whoami which shows me:
[07-Apr-2021 14:26:04 UTC] USER INFO::::
[07-Apr-2021 14:26:04 UTC] root
[07-Apr-2021 14:26:04 UTC] apache
I am calling this at the moment from a simple php page called at http:///test_log.php:
<?php
require("/var/www/html/myproject/app/lib/log_fns.php");
//phpinfo();
my_logger("This is a test message from test_log.php");
?>
I tried to chmod the files to 777 in the ./lib directory but was still getting this error. I have hard coded the path you can see above creating the ulogs directory.
I have tried combinations of chmod the ulogs directory to 777 and chown the directory to apache:apache but still get this error.
Any ideas where I can look next or how to solve?
TIA
Run this command
sudo chmod 777 /var/www/html/myproject/ulogs/
With this work you file_put_contents can generate or edit the file in this directory
This happened to me and no changing of file/folder permissions worked. The issue in the end was SELinux, which is setup as enforcing by default on CentOS.
To disable it, edit /etc/selinux/config, and change
SELINUX=enforcing
to
SELINUX=disabled
Reboot and it should work.

Why does switching to secure folder (httpsdocs) break the PHP file upload function

Server version: Apache/2.4.34 (Unix)
NOTE: This is not a Plesk or control panel questions. This is a custom PHP application hosted on a Rackspace dedicated server with no control panel.
I'm trying to utilize an existing SSL certificate for several sub-directories of a domain, but the architecture for the domain separates out two directories for non-secure/secure:
httpdocs
httpsdocs
I copied everything from httpdocs to httpsdocs and also forced traffic to https using .htaccess. Everything worked great until I tried the PHP file upload functionality.
Here's the bit of code that is failing from the secure side:
$path = "uploaded_files/".$row_query[0].'/'.$file_name;
copy($temp_file, $path);
In doing some debugging, I found that the temp file gets created:
/tmp/phpanKT4N
but the error I see in the logs is:
copy(uploaded_files/New Sub Folder/30052_testing.txt): failed to open stream: Permission denied in /var/www/vhosts/.com/httpsdocs/demo/resource/add_resource.php on line 108
I tried changing copy() to move_uploaded_file() but here's the error for that:
PHP Warning: move_uploaded_file(uploaded_files/test/30054_testing.txt): failed to open stream: No such file or directory in /var/www/vhosts/<thedomain>.com/httpsdocs/demo/resource/add_resource.php on line 111
PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpOC9YEF' to 'uploaded_files/test/30054_testing.txt' in /var/www/vhosts/<thedomain>.com/httpsdocs/demo/resource/add_resource.php on line 111
I searched stack and saw that ownership must match, but the permissions appear to be the same for httpdocs and httpsdocs.
The /tmp folder is owned by root:root and like I said this works perfectly from the non-secure folder. The non-secure and secure upload folders are identical:
httpdocs:
drwxrwxr-x+ 8 theuser apache 4096 Sep 22 2015 uploaded_files
httpsdocs:
drwxrwxr-x+ 8 theuser apache 4096 Sep 22 2015 uploaded_files
Is this a configuration, permissions issue, or what?
Figured this out... Ran the following:
First find apache's user:
egrep -i '^user|^group' /etc/httpd/conf/httpd.conf
Result:
User apache
Group apache
Then ran this and it solved all the PHP file upload issues in httpsdocs:
chown -R apache:apache /var/www/vhosts/<thedomain>.com/httpsdocs/
chmod -R g+rw /var/www/vhosts/<thedomain>.com/httpsdocs/

Laravel: laravel.log permission denied

When I try to open my Laravel app I get the following error:
UnexpectedValueException
The stream or file "/laravel/storage/logs/laravel.log" could not be opened:
failed to open stream: Permission denied
Why is this and how can I fix it?
Write the following within terminal and ensure you are in the projects directory:
sudo chmod -R 777 storage/*
on FINDER right clic on STORAGE (inside ::your disk:: /Applications/XAMPP/xamppfiles/htdocs/laravel) folder and go to INFORMATION, go to bottom SHARING AND PERMISSIONS, there you must give READ AND WRITE permissions to EVERYONE. This option worked for me
NOTE: my OS languaje is SPANISH, may be text have some little variations; please, excuse my english
Maybe if you have installed Cent OS have to disable selinux.
setenforce 0
it will works.

Permission denied in Apache instead of 777

I am having a hard time deploying a PHP website built using Grav on CentOS.
Whenever I try to open the website I get 500 Server Error. The logs say:
Uncaught exception 'RuntimeException' with message 'Creating directory '/var/www/html/glug_site/cache//compiled/files' failed on error mkdir(): Permission denied' in /var/www/html/glug_site/vendor/rockettheme/toolbox/File/src/File.php:420\nStack trace:\...
I followed the guide mentioned here but it didn't helped.
Then, I did chmod 777 -R glug_nith/ but still it doesn't work. I even logged into apache user using sudo -u apache bash to see if I am able to create folders and files inside myapp and I was successful. I tried deleting the .htaccess file to see if that would help but it didn't.
I cannot understand instead of having all the permission why its showing permission denied. Also I couldn't find any thing that might be blocking the permission. Please help.
try uncommenting the 12th line in ur .htaccess file
Modify this
# RewriteBase /
to
RewriteBase /

Categories