Google Answers Logo
View Question
 
Q: Apache launhes and serves 404's ( Answered,   0 Comments )
Question  
Subject: Apache launhes and serves 404's
Category: Computers > Programming
Asked by: bluethundr-ga
List Price: $50.00
Posted: 24 Feb 2005 19:59 PST
Expires: 26 Mar 2005 19:59 PST
Question ID: 480467
I am having some difficulty with the basic setup of apache using
O'Reilly's Apache the Definitive Guide. To my knowledge I have setup
my config to the letter and get a 404 not found error when hitting the
pages supposedly being served off of my own machine locally. 

I am running Fedora 1.0 with Apache 2.0

They suggest using a script which reads as follows:

test -d logs || mkdir logs
/usr/sbin/httpd -f `pwd`/conf/httpd$1.conf -d -`pwd`

the script is called go and was chmod'ed to 777

the path in which go lives is /usr/www/chp2

(reflecting the chapter of the book I am in)

in that direcrory there are directories : conf, htdocs, logs 

inside conf lives httpd.conf (of course) which reads:
Listen cassowary:80 #name of server is cassowary and is reflected in /etc/hosts
Servername cassowary
DocumentRoot /usr/www/chp2/htdocs
User webuser
Group webgroup

the index file living inside htdocs is in mode -rw-r-r and belongs to
the webuser group and user
so I am unclear  as to why this server is serving up 404's after apache starts.

If more clarity is needed I apologize and would be happy to make the
situation clearer.

Thank you!

Clarification of Question by bluethundr-ga on 24 Feb 2005 20:09 PST
The error that is returned when the page is hit is 404 then quickly changes to "
Not Found

The requested URL / was not found on this server. 

httpd launches quietly and without a hitch, but why its serving up a
URL not found page is beyond me.

Thanks!

Request for Question Clarification by leapinglizard-ga on 24 Feb 2005 20:26 PST
This is a mysterious problem. Your Apache server seems to be running
and network-accessible because it's serving the 404 page. You say that
the DocumentRoot exists and has the right permissions. I have only
three suggestions for the time being. Try them out and let me know
what happens.

First, you should probably enclose the argument to DocumentRoot in
double quotes, so it should look like this.

  DocumentRoot "/usr/www/chp2/htdocs"

After you've made the change, restart Apache using the command

  apachectl restart

(you may have to be root to run this) and see if it makes a difference.

Next, you may want to try

  apachectl configtest

to see if it reports any syntax errors.

Finally, you should take a look at the Apache log to see whether it
contains any clues. If you don't know where your log files are
located, find the value of ServerRoot in your httpd.conf, then look
for the file logs/access_log under that directory. Take a look at the
end of the log and see whether it makes any sense. There's also an
error log at logs/error_log under the ServerRoot directory.

Let me know how it works out!

leapinglizard

Clarification of Question by bluethundr-ga on 24 Feb 2005 20:49 PST
Hi there! And  thanks for taking the time to try to answer this
conundrum. I switched paths since downloading the sample sites from
O'Reilly, but that shouldn't be here nor there.

But I tried your suggestion of changing the document root to use
double quotes as you suggest. In this case it's now :
"/usr/www/APACHE3/site.toddle/htdocs".

And as usual , apache gives the thumbs up and launches without a
hitch. But navigating to the server through lynx still yields the 404
error and hitting the site through Mozilla yields still "Not Found"
the requested URLL / was not found on this server.

Running apachectl as you suggest yields a "Syntax OK" message. And so
the mystery thickens and I still am shrugging my shoulders on this
one. Very frustrating, indeed. Especially considering that I _appear_
to be doing everything correctly.

Thanks!
bluethundr

Request for Question Clarification by leapinglizard-ga on 24 Feb 2005 21:50 PST
Have you taken a look at the access_log and error_log files? If you
post, say, the last five lines of each after an attempted web access,
I'll see what I can make of them.

Also, if your httpd.conf doesn't contain any confidential information,
it would help if you could copy it to a functioning web server and
post a link to it.

By the way, does your DocumentRoot contain a file called index.html?
If not, what happens if you add one?

leapinglizard

Clarification of Question by bluethundr-ga on 25 Feb 2005 09:54 PST
Hi, and thanks again for your help. In downloading the example site
from O'Reilly there was no "access_log" file inside the logs folder.
But there is an error_log file. The last five lines read:
------------------------------------------------------------------------------------
[Fri Feb 25 07:15:05 2005] [warn] pid file
/usr/www/APACHE3/site.toddle/logs/httpd.pid overwritten -- Unclean
shutdown of previous Apache run?
[Fri Feb 25 07:15:05 2005] [notice] Apache/2.0.47 (Fedora) configured
-- resuming normal operations
[Fri Feb 25 07:15:48 2005] [error] [client 127.0.0.1] Attempt to serve
directory: /usr/www/APACHE3/site.toddle/htdocs/
[Fri Feb 25 07:16:03 2005] [error] [client 127.0.0.1] Attempt to serve
directory: /usr/www/APACHE3/site.toddle/htdocs/
[Fri Feb 25 07:16:17 2005] [error] [client 127.0.0.1] Attempt to serve
directory: /usr/www/APACHE3/site.toddle/htdocs/

-----------------------------------------------------------------------------------
My httpd.conf file is totally unconfidential. I don't have access to a
functioning webserver at the moment, but the file is tiny. So here are
its contents:

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

User webuser
Group webgroup

ServerName cassowary

Listen 80

DocumentRoot "/usr/www/APACHE3/site.toddle/htdocs/"

#fix 'Out of the Box' default problems - remove leading #s if necessary
ServerRoot /usr/www/APACHE3/site.toddle
#ErrorLog logs/error_log
#PIDFile logs/httpd.pid
#TypesConfig conf/mime.types

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

The only file that came with the sample download was a file called
"1.txt". I did try copying it to a file called index.html and that
didn't change a thing. Lynx still sends the message back "Alert!
HTTP/1.1 404 not found" then quickly takes you to a page that reads:
404 Not found. The requested URL / was not found on this server.
Mozilla yields a window with a title bar that reads 404 not found and
the body of the document is the same as was found in Lynx.

This is driving me nuts!
Thanks!!

Clarification of Question by bluethundr-ga on 25 Feb 2005 09:57 PST
One more note I forgot to address was that "1.txt" was living inside
htdocs as was its copy that I named "index.html"
Answer  
Subject: Re: Apache launhes and serves 404's
Answered By: leapinglizard-ga on 25 Feb 2005 18:44 PST
 
Dear bluethundr,

The solution is to add the following lines to your httpd.conf file.


# sets the file that Apache will serve if a directory is requested
DirectoryIndex index.html

<Directory "/usr/www/APACHE3/site.toddle/htdocs/">
  # gives a directory listing if no DirectoryIndex file is found
  Options Indexes
</Directory>


After you restart, you should be able to access the root document of
your web server.

The reason you were getting 404 errors is that Apache doesn't know
by default how to behave when a web client specifies a directory name
as the URL. You see, the fundamental obligation of a web server is to
serve files. If a client only gives the name of a directory, Apache is
confused. Does the client actually want a file, and if so, which one?

The DirectoryIndex directive by itself is enough to solve this problem as
long as the requested directory contains a file whose name matches one of
the directive values. You can specify several values separated by spaces.

Apache 2.0: DirectoryIndex Directive
http://httpd.apache.org/docs-2.0/mod/mod_dir.html#directoryindex

The remaining lines I gave you are strictly optional. The Directory
directive specifies that the enclosed material should apply recursively
to the named directory and all its subdirectories.

Apache 2.0: Directory Directive
http://httpd.apache.org/docs-2.0/mod/core.html#directory

The enclosed line uses the Options directive to turn on the Indexes
option, which mandates that if a directory is requested but it contains
no file matching a DirectoryIndex value, Apache should instead return a
listing of the directory contents. Some people do without this option for
privacy and security reasons, but I find it convenient on my own server.

Apache 2.0: Options Directive
http://httpd.apache.org/docs-2.0/mod/core.html#options

It has been a pleasure to address this question on your behalf. If you
feel that any part of my answer requires correction or elaboration, do
let me know through a Clarification Request so that I have the chance
to fully meet your needs before you assign a rating.

Regards,

leapinglizard
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy