Tell SELinux to Give Apache Execute Access to PHP Files Outside Document Root

后端 未结 2 1839
情歌与酒
情歌与酒 2020-12-11 18:46

I have a directory where shared PHP scripts are kept (the name is arbitrary, but it isn\'t /var/, /usr/, or anything that SELinux would have specific settings for):
/w

相关标签:
2条回答
  • 2020-12-11 19:12

    I use this with the executable programs I need to run from my PHP scripts and Apache

    sudo chcon -v -t httpd_sys_script_exec_t my-executable
    
    0 讨论(0)
  • 2020-12-11 19:21

    I found the solution with these two commands:

    semanage fcontext -a -t httpd_sys_script_exec_t '/whatever/scripts(/.*)?'
     
    restorecon -R -v /whatever/scripts/

    That allows Apache to execute PHP scripts in that directory, and persists after a reboot, or system-wide relabeling.

    0 讨论(0)
提交回复
热议问题