Apache user privileges in Centos

Hi, I am using the shell_exec command from a PHP script:

$output = shell_exec('ls -l');
print_r($output);

Terminal: php test.php

Which leads to a list of directories as expected.

Switch to my browser. I do not get a way out.

I need to grant privileges to the apache user so that he can execute certain commands or add the user to a group with such privileges. I know how to add users to groups, etc. I'm just wondering which best practice method provides such privileges to apache user.

+3
source share
2 answers

It took me a while to realize that this could benefit others.

, apache /etc/sudoers, SELinux ( ) .

SELinux httpd, .

, -.

, audit2allow.

0

ls -Z , , SELinux .

httpd/apache , ( -R ):

chcon -Rv --type=httpd_sys_content_t /desired/path

, .

0

Source: https://habr.com/ru/post/1770477/


All Articles