I\'ve cloned a laravel repo to my CentOS 7 box. When I try to run it, I get a 500 error with nothing displayed.
So I check out /var/log/httpd/error_log
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
On CentOS 7 I had similar permissions issue. The solution which works for me is:
Add user centos to group apache
Add user apache to group centos
Restart httpd
The final line is vital as otherwise user apache will not be aware it is now also in group centos!
Same as user apache logging out and back in again.
try these worked for me ...
sudo find ./storage -type f -exec chmod 666 {} \;
sudo find ./storage -type d -exec chmod 777 {} \;
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!
Apply this for whole project.
chcon -R -t httpd_sys_rw_content_t project_folder