Solution:
Method One:
Change the directory or file's policy type to httpd_sys_content_t.
# chcon-r-h-t httpd_sys_content_t/www/web/
You can then use the Ls-laz command to view the policy type of the file directory.
Method Two:
Disable SELinux
Linux system looks like there is a selinux security mechanism, check the status bar.
[Root@localhost home]# Getenforce
Enforcing
Sure enough, SELinux was turned on, and it was forced mode.
The directory is set to the user_home_t type, and the Apache process has no permissions and cannot be accessed.
The SELinux target policy used for the Apache process stipulates that the Apache process can only access directories or files of the httpd_sys_content_t type. So as long as the relevant permissions can be modified. Solution:
1. Change Folder permissions
Chcon-t httpd_sys_content_t/home/www/
Chcon-t httpd_sys_content_t/home/www/html/
Then ls-z view directory Permissions
Look, the permissions have been changed to httpd_sys_content_t. So you can start the httpd.
2. Shut down SELinux shut down SELinux need to reboot the system,
The modified method is: Vi/etc/selinux/config Modify selinux=disabled
Then reboot the system and close the SELinux.
++++++++++++++++++++++++++++++++++++++++++++++++
Another article of reference:
Apache hints DocumentRoot must be a directory
System environment: Scientific Linux Release 6.2
Change DocumentRoot to/home/godontop/www prompt:
Starting Httpd:syntax error on line 293 of/etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory
[Root@sl ~]# getsebool-a |grep httpd_enable_homedirs
Httpd_enable_homedirs--> off
It turns out that SELinux is not allowed to use the home directory as a web directory!
Modify SELinux Settings
View sourceprint?1 [Root@sl ~]# setsebool httpd_enable_homedirs on
Then restart Apache, everything's fine.
[ROOT@SL ~]# Service httpd restart
stopping httpd: [OK]
Starting httpd: [OK]