Problem
I have installed Apache 2.2.3 on my web server. After installation, I made some changes in httpd.conf file and created the required directory for DocumentRoot but when I tried to start the HTTPD service I got the below error:
[root@dbappweb ~]# service httpd start Starting httpd: Syntax error on line 302 of /etc/httpd/conf/httpd.conf: DocumentRoot must be a directory [FAILED]
DocumentRoot is defined in the httpd.conf file was a directory and when I checked the httpd syntax then I got that there was no syntax error as shown below.
[root@dbappweb ~]# httpd -t Syntax OK
Reason
Starting of httpd service was being failed because the SELinux feature was Enforcing, it can be checked using the command getenforce.
[root@dbappweb ~]# getenforce Enforcing
Solution
To resolve the above issue you need to disable the SELinux feature. To disable the SELinux feature you need to edit the /etc/selinux/config file. Change the value of SELINUX from enforcing to disabled. After changing the value you need to reboot the server.
[root@dbappweb ~]# vi /etc/selinux/config . . # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted . .
Once the server is rebooted these changes will come into effect which can be verified using the command getenforce and its output should be disabled.
[root@dbappweb ~]# getenforce Disabled
Now You can start the apache service successfully.
[root@dbappweb ~]# service httpd start Starting httpd: [ OK ]
Note: I faced the above problem on RHEL 5.8 while installing the Apache 2.2.3