Apache DocumentRoot must be directory

You have created a separate partition for you htdocs folder and mounted it on /path/to/documentroot. However, when you try to start Apache you get following error ‘DocumentRoot must be directory’.

This is due to SELinux to get Apache working you have 2 ways

  1. Crude way:- disable SELinux altogether
  2. Eligible way:- set SELinux context to that directory

Crude way:- disable selinux altogether

Follow below steps:

vi /etc/selinux/config
Change 'SELINUX=enforcing' to 'SELINUX=disabled'
Restart your system

Eligible way:- set SELinux context to that directory

First check the SELinux context of the directory with following command.

ls -laZ /path/to/documentroot

Follow below steps:

chcon -R -h -t httpd_sys_content_t /path/to/documentroot

Verify the SELinux context

ls -laZ /path/to/documentroot

Restart your Apache and it works :).

Hope this saves your time.

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*


CommentLuv badge