[SOLVED] Apache: DocumentRoot must be a directory

General support questions
sayres
Posts: 93
Joined: 2011/06/25 16:05:45
Location: Iran/Karaj

[SOLVED] Apache: DocumentRoot must be a directory

Post by sayres » 2011/07/31 14:40:32

I just installed CentOS 6 and modified /etc/httpd/conf/httpd.conf like this:
[code]DocumentRoot "/home/sayres/Web"[/code]

However, after doing this, every time I tried to start httpd it gives me the error:

[code]

[root@centos ~]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: Syntax error on line 292 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory
[FAILED]
[root@centos ~]#

[/code]

What can I do?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache: DocumentRoot must be a directory

Post by TrevorH » 2011/07/31 21:21:35

Make sure the directory exist? Make sure that the apache user can read it and can see inside it? Check its selinux context to make sure that Apache is allowed to access it? Or perhaps better, use /var/www/html which already has all of those attributes set up correctly out of the box?

sayres
Posts: 93
Joined: 2011/06/25 16:05:45
Location: Iran/Karaj

Re: Apache: DocumentRoot must be a directory

Post by sayres » 2011/07/31 21:34:39

[code]Check its selinux context to make sure that Apache is allowed to access it[/code]
who??

i want install joomla 1.5 and now my document root is: /var/www/html

but when run joomla index.php for installation :
http://127.0.0.1/Joomla/
encounter a massage:

[code]Forbidden 403
You don't have permission to access /Joomla/ on this server.
Apache/2.2.15 (CentOS) Server at localhost Port 80[/code]

what i can doit???

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache: DocumentRoot must be a directory

Post by TrevorH » 2011/07/31 21:44:59

Post the output from

[code]
ls -laZ /var/www/html
sestatus
[/code]

sayres
Posts: 93
Joined: 2011/06/25 16:05:45
Location: Iran/Karaj

Re: Apache: DocumentRoot must be a directory

Post by sayres » 2011/07/31 22:00:05

[code]

[sayres@centos ~]$ ls -laZ /var/www/html/
drwxrwxr-x. root sayres system_u:object_r:httpd_sys_content_t:s0 .
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 ..
-rw-rw-r--. root sayres unconfined_u:object_r:httpd_sys_content_t:s0 info.php
drwxr-xr-x. root sayres unconfined_u:object_r:user_home_t:s0 Joomla
[sayres@centos ~]$


[/code]

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache: DocumentRoot must be a directory

Post by TrevorH » 2011/07/31 22:17:18

[quote]
drwxr-xr-x. root sayres unconfined_u:object_r:user_home_t:s0 Joomla
[/quote]

Yes, the selinux context is wrong so it will not let that directory be accessed by apache. To fix this, the easy way is to run as root

[code]
chcon -R --reference=/var/www/html /var/www/html/Joomla
[/code]

For reference, to prevent this in the future, don't untar something in your home directory and then move it to /var/www/html.

sayres
Posts: 93
Joined: 2011/06/25 16:05:45
Location: Iran/Karaj

Re: Apache: DocumentRoot must be a directory

Post by sayres » 2011/07/31 22:29:28

tanks dude...
how i can check selinux ????

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

[SOLVED] Apache: DocumentRoot must be a directory

Post by pschaff » 2011/07/31 22:38:29

http://wiki.centos.org/HowTos/SELinux
http://wiki.centos.org/TipsAndTricks/SelinuxBooleans

Also for future reference, please start a new Topic for a new question, rather than hijacking your own thread.

sayres
Posts: 93
Joined: 2011/06/25 16:05:45
Location: Iran/Karaj

Re: Apache: DocumentRoot must be a directory

Post by sayres » 2011/07/31 22:45:41

tanks.

[solved]

User avatar
AlanBartlett
Forum Moderator
Posts: 9345
Joined: 2007/10/22 11:30:09
Location: ~/Earth/UK/England/Suffolk
Contact:

Re: [SOLVED] Apache: DocumentRoot must be a directory

Post by AlanBartlett » 2011/08/01 00:40:07

For posterity, and as requested by the OP, this thread is marked [SOLVED].

Post Reply