PDA

View Full Version : apache error



tgone
28th April 2006, 10:29 AM
Hello,

I get the following error when I try to restart Apache:



[tony@localhost ~]$ /usr/sbin/apachectl restart
apachectl: Configuration syntax error, will not run "restart":
Syntax OK

Then I ran this command to make sure I didn't have a syntax error:



[tony@localhost ~]$ /usr/sbin/apachectl configtest
Syntax OK


The only thing I changed in my httpd.conf was the DocumentRoot. I've looked over the file 10 times but I don't see any syntax errors.

To make it even more interesting, this is what happens when I try to start Apache.



[tony@localhost ~]$ sudo /usr/sbin/apachectl start
Syntax error on line 280 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory


I *know* for sure that this directory exists and the permissions are 755. I don't know what's going on here. Any ideas?

Mat
28th April 2006, 11:07 AM
(moved to Server)


if you only changed the DocumentRoot setting, what does this line read?



Mat

fire-fly
28th April 2006, 11:10 AM
Hello,

I get the following error when I try to restart Apache:



[tony@localhost ~]$ /usr/sbin/apachectl restart
apachectl: Configuration syntax error, will not run "restart":
Syntax OK

Then I ran this command to make sure I didn't have a syntax error:



[tony@localhost ~]$ /usr/sbin/apachectl configtest
Syntax OK


The only thing I changed in my httpd.conf was the DocumentRoot. I've looked over the file 10 times but I don't see any syntax errors.

To make it even more interesting, this is what happens when I try to start Apache.



[tony@localhost ~]$ sudo /usr/sbin/apachectl start
Syntax error on line 280 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory


I *know* for sure that this directory exists and the permissions are 755. I don't know what's going on here. Any ideas?

do you might stating your DocumentRoot syntax you can rename your content for security reason.
Any clude from the errror log ?

tgone
28th April 2006, 11:27 AM
do you might stating your DocumentRoot syntax you can rename your content for security reason.
Any clude from the errror log ?

DocumentRoot "/home/webadmin/html/"

and there is nothing in the error log. :eek:

djvaporz
28th April 2006, 12:09 PM
Try this DocumentRoot "/home/webadmin/html" and make sure that <Directory "/home/webadmin/html"> is also there instead of <Directory "/var/www/html">

tgone
28th April 2006, 10:57 PM
Try this DocumentRoot "/home/webadmin/html" and make sure that <Directory "/home/webadmin/html"> is also there instead of <Directory "/var/www/html">

They are the same. I don't know what to do. I was running Apache fine on Fedora 5 and then I reinstalled (Fedora) and this problem came up. I've searched Google but I can't find anyone else with the same problem. Maybe I should just reinstall again?

icydog
29th April 2006, 12:08 AM
Run setenforce 0 as root and see if that makes it work. If so, it's SELinux and someone here will have a solution for you.

Mat
29th April 2006, 12:33 AM
according to apache's manual, djvaporz suggestion (no trailing slash) should work



Mat

tgone
29th April 2006, 02:43 AM
according to apache's manual, djvaporz suggestion (no trailing slash) should work


Mat

I tried removing the trailing slash and I have the same problem. I don't think this is a syntax error because it happens with the default conf file.

I've tried reinstalling Fedora 5 a couple times and I still have the same problem. I wonder if this has to do with a firewall or some other security setting.

tgone
29th April 2006, 02:47 AM
Run setenforce 0 as root and see if that makes it work. If so, it's SELinux and someone here will have a solution for you.

What is "setenforce 0'? do you mean "set enforce = 0'.

gavinw6662
29th April 2006, 03:54 AM
this is just a stab in the dark. But did you verify that there was a Directory there (where you told apache the document root is)? I am hoping you aren't trying to configure apache before actually creating that folder. Also - please sure it is a directory and not a file (whereever you set your Doc Root).

That is what I can get from your error:

DocumentRoot must be a directory

icydog
29th April 2006, 04:34 AM
What is "setenforce 0'? do you mean "set enforce = 0'.
setenforce is an SELinux command. "setenforce 0" is a command you type into a root shell. setenforce 0 makes SELinux permissive so that it doesn't restrict anything, and setenforce 1 sets it to enforcing. So if you type setenforce 0, then apachectl start, and it works, then SELinux is the problem.

You mentioned that you get the error with the default conf file. That's very weird. Are you installing Apache from the FC5 repos?

tgone
30th April 2006, 03:52 AM
setenforce is an SELinux command. "setenforce 0" is a command you type into a root shell. setenforce 0 makes SELinux permissive so that it doesn't restrict anything, and setenforce 1 sets it to enforcing. So if you type setenforce 0, then apachectl start, and it works, then SELinux is the problem.

You mentioned that you get the error with the default conf file. That's very weird. Are you installing Apache from the FC5 repos?

It worked!

I ran setenforce 0 at shell and also set the level in system > security level and firewall to be safe. I can now restart Apache without any errors.

Thanks to everyone who helped me.

icydog
30th April 2006, 08:07 AM
You probably want to turn SELinux on when you actually run your server, though. I only suggested using setenforce 0 to see if SELinux was the problem. Now that you know it IS the problem, I think you should figure out specifically what SELinux is doing.

If you have this in your conf file:

DocumentRoot "/home/webadmin/html"

Then try something like this:

$ ll -Zd /home/webadmin/html
drwxrwxr-x webadmin webadmin system_u:object_r:httpd_sys_content_t /home/webadmin/html

It should show "httpd_sys_content_t." If not, use chcon -t httpd_sys_content_t to set it.

Also, you may need to run system-config-securitylevel and under HTTPD Service in the SELinux tab, check some of those boxes. Specifically, you'll need "Allow HTTPD to read home directories" checked and whatever else as you see fit.

Some people say to not use SELinux at all, but if it's giving you a hard time imagine what it'll do for hackers =) So I say learn to work with it.

dabang
6th May 2006, 04:13 PM
Hi there!

I have the same problem as tgone and tried icydogs suggestions, but still the same problem. When I point "document root" to the default "/var/www/html" everything works fine, pointing it somewhere else ends up as mentioned above, so I cannot start apache. It has something to do with SElinux... As I don't want to turn it off, I hope somebody around here has a solution?
Thanks in advance!

icydog
6th May 2006, 11:47 PM
Can you post the relevant portions of httpd.conf, and also the output of ls -Zd on the DocumentRoot?

dabang
7th May 2006, 08:34 AM
Sure!

$ ll -Zd /mnt/pinguin/entwicklung
drwxrwxrwx dabang dabang system_u:object_r:httpd_sys_content_t /mnt/pinguin/entwicklung

everyboddy has read/write access to this directory.

and httpd.conf:

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/mnt/pinguin/entwicklung"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/mnt/pinguin/entwicklung">