Linux+apache start Prompt "Document root must be a directory"

Source: Internet
Author: User


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


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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.