Before you yell DUPLICATE! and banish me into the abyss, hear me out. :)
I've been developing an intranet site for the company I work with, and originally I was developing it directly from my workstation running Windows 7 / IIS. As I've neared completion of the site/applications, I was given a Centos 7 box that's running Apache, so I've begun the process of migrating it over to that system. I've sorted out most of the minor issues, and got the site running now. However, there is a portion of the site that interacts with our database and creates a log directory/file based upon the person that's logged in. This portion utilizes the mkdir() function, but I'm getting permission issues with it.
mkdir(): Permission denied
Here is what I've already done:
So whether I use chmod or chown to change the permissions for the folders being accessed, I'm getting the same type of error. To be on the safe side, I checked the PHP user also, and it's using the apache user as well.
If anyone may have additional insight as to why it isn't working, even with the permissions changed, then please enlighten me. If I happened to miss the one article that explained this particular situation, then yell duplicate and banish me to the abyss. lol :)
EDIT Okay, so upon further testing, I've discovered 2 issues that seem to be causing this overall issue.
Just to note, I've attempted to set the recursive value to true on mkdir in PHP, but that's when I get the permission issues originally noted. When recursive/mode is removed, it doesn't get the permission issue, but it isn't able to create nested directories.
EDIT2
To test my theories, I removed the nesting and tried to make mkdir create just 1 directory, and it's generating the same errors as before. Although it's owned by Apache, and even if I set it to 777, it throws back permission issues.
[ErrorException] mkdir(): Permission denied Create a new folder, say 'myproject and run sudo chmod 777 myproject . Then move to 'myproject' folder and create project. To solve this problem, go into your laravel project, make your public directory writable.
There are a couple of possible solutions to this issue: Create a folder that the user running the build has permissions to. Change the ownership of the directory with the chown command before trying to write to it.
Could be that although you have 755/777 permissions, SELinux is blocking httpd from writing/creating dirs.
Try:
chcon -R -t httpd_sys_content_t /path/to/www
chcon -R -t httpd_sys_content_rw_t /path/to/www/dir/for/rw
Further info: http://wiki.centos.org/TipsAndTricks/SelinuxBooleans
Not sure but your Centos's PHP binaries may have broken file permissions. There are two ways to fix this up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With