Solve the Problem of httpd. conf: DocumentRoot must be a directory Error

Source: Internet
Author: User

Today, after modifying the DocumentRoot directory of the httpd. conf file and restarting the HTTPd service, an error is reported.
DocumentRoot must be a directory
. At first, I thought it was a problem with my own configuration. Then I checked it and confirmed that the configured DocumentRoot is a directory. Ah, I had to Baidu for a moment. Haha,
It seems that many people have encountered such errors. In summary, there are two possible causes for the DocumentRoot must be a directory error.

1. the DocumentRoot directory configuration contains Chinese Characters

If your DocumentRoot directory contains Chinese characters, change it to English first. Haha ...... If not, let's take a look.

2. SELinux's security policy is tricky.

This is because after the SELinux security policy is enabled, the system sets directories or files to various types,
For example, home_root_t and user_home_t. Some Apache processes do not have the permission to access the DocumentRoot you just set. For
The SELinux Security Policy of Apache processes only allows access
Httpd_sys_content_t directory or file. So you can change the policy type of the directory or file to httpd_sys_content_t. Modify the command as shown in Figure
Below:

Chcon-R-H-T httpd_sys_content_t/Data/Coderbolg/ 

You can use LS-Laz to check whether the Directory Policy type is successfully modified. If this step is completed, an error will be reported ...... You have to look down.

3. Disable SELinux

If you are suffering from SELinux, there is no way. Disable SELinux directly. The system's anxiety is always less important than the server's access right. Directly edit the SELinux configuration file.

 
Vim/Etc/Sysconfig/SELinux

Change the value of SELinux from enforcing to disabled. Save the disk and exit. This is a good deal. If not, restart the server.

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: info-contact@alibabacloud.com 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.