Permissions Issue with Laravel on CentOS

前端 未结 6 2006
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 00:35

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

相关标签:
6条回答
  • 2020-12-01 00:50

    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/

    0 讨论(0)
  • 2020-12-01 00:53

    In my case it was another unix user so this one worked:

    chown -R php-fpm:php-fpm storage
    
    0 讨论(0)
  • 2020-12-01 00:53

    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.

    0 讨论(0)
  • 2020-12-01 01:04

    try these worked for me ...

    sudo find ./storage -type f -exec chmod 666 {} \;
    sudo find ./storage -type d -exec chmod 777 {} \;
    
    0 讨论(0)
  • 2020-12-01 01:10

    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 command

    setenforce 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!

    0 讨论(0)
  • 2020-12-01 01:11

    Apply this for whole project.

    chcon -R -t httpd_sys_rw_content_t project_folder
    
    0 讨论(0)
提交回复
热议问题