# HTTPD: (server/document)root must be a valid directory



## FallFromINFINITY (May 13, 2008)

Apologies if this is the wrong place to ask such a thing, but I have always been given great answers from these forums, so I chose here first.

I currently have a small server set up, CentOS v5.8 x86, server, no GUI.

Attempting to configure httpd, I find myself unable to start the server, returning an error "serverroot must be a valid directory". I have tried many configurations, and in the few that happened to work, documentroot returned the same results.

# service httpd start
Starting httpd: httpd: Syntax error on line 57 of /etc/httpd/conf/httpd.conf: ServerRoot must be a valid directory

line 57:
ServerRoot "/www"


```
# ls -l /
drwxr-x--x 7 apache apache 4096 Dec_5_15:09 /www
```
The same permissions/owner/group (751,apache,apache) are the same on all files in the directory. Each directory has at least 1 file.

The strangest thing, when changing ServerRoot to "/", it does not return an error. (but proceeds to return the same error on line 284, DocumentRoot "/www")


```
# ls -l /
drwxr-xr-x 25 root root 4096 Dec_5_15:09 .
```
Apache doesn't own this, doesn't have write perms, and isn't part of "root" group, yet still is able to use this as serverroot, and documentroot. (the problem being, I'd really rather not have the root directory as apache's server or document root, if at all possible...)

Does anyone have any ideas of what could be the issue with this? I have been trying for days to figure out just what it is that is causing it to be unable to use /www, while it has no issue using directories that it doesn't even own.


----------



## gurutech (Apr 23, 2004)

Default "root" for a web server on a Linux system is /var/www/html

Edit your httpd.conf file to point to that folder, and ensure all your data is in that folder and/or subfolders of that one.


----------



## FallFromINFINITY (May 13, 2008)

gurutech said:


> Default "root" for a web server on a Linux system is /var/www/html
> 
> Edit your httpd.conf file to point to that folder, and ensure all your data is in that folder and/or subfolders of that one.


This I do understand. The setting ServerRoot is actually what sets that folder. This is what I am trying to change at the moment. There are a variety of reasons why I am attempting to place it in a different directory.

------------------------------------------------------------------------

It comes to my attention that I did forget something that may prove fairly important.

But one of the main reasons that I have this set up this way, is because the /www directory is the mount point of a separate harddrive.


----------



## gurutech (Apr 23, 2004)

You may need to mount the drive before you load your web server.

You may also need to mount the drive in a sub-folder of /www (I mount all my data drives under /media/(disk name) - maybe make a /media/www and mount it there; then create a symlink from /var/www/html to your mount point....


----------



## FallFromINFINITY (May 13, 2008)

The drive itself is currently mounted on boot, while apache currently needs to be started manually. I will try mounting it elsewhere to see what the results are.

--------------

EDIT:

So, just attempted a few things.


```
# umount /www
# mkdir /media/www
# mount /dev/sdc1 /media/www
# rm -r /var/www/html
# ln -s /media/www /var/www/html
```
httpd.conf line 57:

```
ServerRoot "/var/www/html"
```


```
# service httpd start
Starting httpd: httpd: Syntax error on line 57 of /etc/httpd/conf/httpd.conf: ServerRoot must be a valid directory
```
I also tried pointing it directly at /media/www/ and at /media/www/test/
Both resulted in the same error.

Is there a setting that apache needs when using files in an alternate mount than what it is installed on? I could not find any information saying that it does.


----------



## gurutech (Apr 23, 2004)

How about mounting your additional hard drive under /var/www/html ?


----------



## FallFromINFINITY (May 13, 2008)

This also resulted in the same error.

The error seems definitively tied to the fact that it is a separate harddrive, as I have tested pointing apache to the other mount points of the other harddrives and partitions, all resulting in the same error. I have also tried pointing to subdirectories of the harddrives, with no luck.

Perhaps I will provide all the information about the harddrives here.

sda is the main harddrive of the system, mounted on root "/"
sdb partitions 1 and 2, mounted on "/home" and "/boot" respectively
sdc 1 and 2 are mounted on "/www" and "/sys"
and finally sdd contains standalone software, currently mounted on "/mcs"
All drives contain a 2GB swap at the end of each drive, and all partitions/drives are ext-3 format and all were designated and formatted on install, and are mounted in those locations on startup from the fstab configuration(which has not been changed since created on install).

Any folders that I target as ServerRoot/DocumentRoot that are on sda, have no issues. Pointing it to any mounted drive, or any subfolders in the drive, result in the error. I see no reason that this would be causing any issues, as I have done similar setups in the past, and have had no problems. I am assuming that this install of the OS/apache did not contain a setting that was present on past setups.


----------



## gurutech (Apr 23, 2004)

I'm at a loss now... other than removing and reinstalling Apache. May want to give that a shot, or post on a Centos forum.

Maybe upgrading Centos to the latest version (I believe it's 6.3) would help as well...


----------

