Permissions Issue with Laravel on CentOS
I need to make more adjustments for SELinux than just for storage
. Especially the config
dir can get you this issue on Laravel bootstrapping.
If you sudo setenforce permissive
and it works, then turn it back sudo setenforce enforcing
then follow below.
SELinux laravel setup:
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/site/laravel/storage(/.*)?"
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/site/laravel/bootstrap/cache(/.*)?"
You may not need the following one for config
, but i did. It may be safest not to run this one unless you need to:
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/site/laravel/config(/.*)?"
Then Reset after your dir adjustments have been made:
restorecon -Rv /var/www/site/
In my case it was another unix user so this one worked:
chown -R php-fpm:php-fpm storage
try these worked for me ...
sudo find ./storage -type f -exec chmod 666 {} \;
sudo find ./storage -type d -exec chmod 777 {} \;
Turns out the issue is with selinux
I found this answer, which solved my problem.
Prove this is the problem by turning off
selinux
with the commandsetenforce 0
This should allow writing, but you've turned off added security server-wide. That's bad. Turn SELinux back
setenforce 1
Then finally use SELinux to allow writing of the file by using this command
chcon -R -t httpd_sys_rw_content_t storage
And you're off!