1

i recently install yii2 app and after all setup i realize that i keep getting permission error and after a lot of search i notice there's nothing wrong with my setup but the problem is with SElinux mode being set to enforcing, so when i try to set the mode to disabled that solve the permission problem so i need help on how to allow SElinux give permission to directory for example

/var/www/

give permmision to all the content of /var/www and the subdirectory

any help would be appreciated

I edited my question to include this portion as I also face the same problem with nginx so i'd appreciate if there's different ways of solving this problem for the two web server because from my search i saw something like

chcon -Rv --type=httpd_user_content_rw_t /var/www/html/yii/ 

which specifically mention httpd and to my knowledge i thought it's only referring to apache, so any idea on how to solve same issue for different web server would be appreciated

0

1 Answer 1

0

For an individual file in nginx, you can change the context like this

# semanage fcontext -a -t httpd_sys_content_t /www/file.txt
# restorecon -v /www/file.txt

For a group of files, you would do it like this:

# semanage fcontext -a -t httpd_sys_content_t /var/www(/.*)?
# restorecon -Rv /var/www/

Source: nginx.com, Option 1: Modify the File Label

1
  • Answer looks good but if I don't use quotation mark around /var/www(/.*)? bash complains. Test your solution and change your answer if you got the same conclusion.
    – supi007
    Commented Sep 25, 2023 at 10:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .