LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (http://www.linuxquestions.org/questions/debian-26/)
-   -   Apache2 Server...File not found /htdocs (http://www.linuxquestions.org/questions/debian-26/apache2-server-file-not-found-htdocs-589713/)

scottley 10-05-2007 12:45 PM

Apache2 Server...File not found /htdocs
 
Excerpt from logs:

Code:

< [Thu Oct 04 13:38:53 2007] [error] [client 127.0.0.1] File does not exist: /htdocs
< [Thu Oct 04 13:38:54 2007] [error] [client 127.0.0.1] File does not exist: /htdocs
< [Thu Oct 04 13:38:55 2007] [error] [client 127.0.0.1] File does not exist: /htdocs
< [Thu Oct 04 13:39:33 2007] [error] [client 127.0.0.1] File does not exist: /htdocs

this happens quite frequently and persists throughout the day. Google searches for this error show that there "should" be something wrong in my apache2.conf. I have no references to /htdocs in my conf, but this one strange output makes me think that this may be an apache2 default:

Code:

myhostname# apache2 -V
Server version: Apache/2.2.3
Server built:  Jun 17 2007 20:24:06
Server's Module Magic Number: 20051115:3
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture:  32-bit
Server MPM:    Prefork
  threaded:    no
    forked:    yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT=""
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

note the
Code:

-D HTTPD_ROOT=""
do I need to explicitly set an httpd root in the apache2.conf or is this handled in a virtual hosts entry. I'm working on a web server with over 20 sites on it, so each virtual host is given it's own DocumenRoot and I thought the
Code:

ServerRoot "/etc/apache2"
would point HTTPD_ROOT to something (this is the default from the install, i did not change it)

Any help is much appreciated.
Cheers!

norobro 10-07-2007 01:26 PM

Scottley,

Just a WAG but do you have a "Document Root" directive for all of your virtual hosts? According to the Apache docs the default document root is "ServerRoot"/htdocs.

Also whatever is causing the error is accessing your server through the loop-back (127.0.0.1). What's up with that?

Norm

scottley 10-08-2007 12:13 PM

Quote:

Also whatever is causing the error is accessing your server through the loop-back (127.0.0.1). What's up with that?
It seems to be that if you don't assign a specific IP to apache it does it's thing through the loopback.
Quote:

Just a WAG but do you have a "Document Root" directive for all of your virtual hosts? According to the Apache docs the default document root is "ServerRoot"/htdocs.
I have a DocumentRoot for each of my VHosts, yes. my ServerRoot is set to:
ServerRoot "/etc/apache2"
in Apache2.conf, but the:
-D HTTPD_ROOT=""
seems to be taking precedence.
I can get the error to stop by creating a /htdocs directory (based off /), but this is just a hack. This /htdocs directory is the only htdocs on my system (the one that I created).

norobro 10-09-2007 07:57 AM

I finally see what you are saying. The error is relative to the compiled-in ServerRoot not the ServerRoot in your config file. I tried unsuccessfully to replicate this error on a machine that I have.

Does your access log give you any clue about what is happening at the time of the error(s)?

Norm

farslayer 10-09-2007 03:08 PM

usually the document root for apache(2) is /var/www isn't it ?

Code:

username@it-etch:~$ cd /var/www
username@it-etch:/var/www$ ls
apache2-default

username@it-etch:/var/www$ ls apache2-default
apache_pb22_ani.gif  apache_pb22.png  apache_pb.png
apache_pb22.gif      apache_pb.gif    index.html

at least on most systems I have worked on..

norobro 10-09-2007 05:42 PM

Yep, /var/www on most systems I think, but it can be any directory.

What Scottley is pointing out, and it took two posts for me to get it, is that the server is trying to serve files from /htdocs. In his config file the statement
Code:

ServerRoot "/etc/apache2"
should tell the server to look in
Code:

/etc/apache2/htdocs
and this would only be the default case i.e. a virtual host with no DocumentRoot statement.

At least that is the way that I understand it. Could be wrong though.

Norm

scottley 10-09-2007 08:21 PM

I have 20 something sites hosted on this server (I'm not an apache noob, but this server was recently upgraded to apache2, which I Have less experience with). Each site has it's own DocumentRoot, ServerName, ServerAlias, and Directory directives (follow symLinks, etc).
the errors are so often and only related to the default VHost (which has a DocumentRoot of /var/www/), that I'm led to believe that it is a module, not Apache2 causing the error. I have openSSL and PHP installed on this server.
The Apache 2 install that I used was through apt-get. I did not compile this myself (probably my first mistake, but it's sooo easy).
I have made the errors stop by adding the directory /htdocs/, but I don't like this hack. I don't see any errors for something looking for a file in /htdocs/ (e.g. File Not Found /htdocs/<some file>).
I just had a thought....
Could this File not found /htdocs/ error be some kind of security check that Apache2 (or some loaded module) looking to see if it can access files in /htdocs?
This is probably a WAG, but it seems logical. A good analog to my hypothesis is in osCommerce, whenever a page is loaded, it touches /include/configure.php to see if it is protected or writeable and displays a warning bar stating that the configure.php is writeable

Uther Pendragon 06-19-2009 04:17 PM

Quote:

Originally Posted by scottley (Post 2919083)
I have 20 something sites hosted on this server (I'm not an apache noob, but this server was recently upgraded to apache2, which I Have less experience with). Each site has it's own DocumentRoot, ServerName, ServerAlias, and Directory directives (follow symLinks, etc).
the errors are so often and only related to the default VHost (which has a DocumentRoot of /var/www/), that I'm led to believe that it is a module, not Apache2 causing the error. I have openSSL and PHP installed on this server.
The Apache 2 install that I used was through apt-get. I did not compile this myself (probably my first mistake, but it's sooo easy).
I have made the errors stop by adding the directory /htdocs/, but I don't like this hack. I don't see any errors for something looking for a file in /htdocs/ (e.g. File Not Found /htdocs/<some file>).
I just had a thought....
Could this File not found /htdocs/ error be some kind of security check that Apache2 (or some loaded module) looking to see if it can access files in /htdocs?
This is probably a WAG, but it seems logical. A good analog to my hypothesis is in osCommerce, whenever a page is loaded, it touches /include/configure.php to see if it is protected or writeable and displays a warning bar stating that the configure.php is writeable

I had this problem too, turned out the request was to a virtual host that didn't exist...

in my case, I had two ports open for apache, and the request was made to the second port for a virtual host that was only setup on the first port.

Ultimately, I think this is happening because its to a Virtual host that does not exist, or to an ip address.

just add a DocumentRoot=/path/to/web/files in your main apache2.conf, which will apply to all requests that don't match a configured virtual host. In debian, mine didn't have by default. I added it and it worked. In addition, if you don't want those requests to succeed, then deny all in the directory section:
<Directory /path/to/web/files>
deny from all
</Directory>

seems right that it tried /htdocs as that was the compiled default, and I'm guessing you had no other document root specified outside a vhost.

kamiltux 08-11-2010 10:31 AM

Old thread - new for me...
 
I recently had the same problem when I removed iscp(free clone of cPanel).
Try to add in /etc/apache2/apache2.conf the following line:

Code:

Include /etc/apache2/sites-enabled/
Include /etc/apache2/sites-available/

Reinstallation of Apache did not help for me.

SimonKing 11-07-2012 01:35 PM

I got the same problem before. And this is why I got this complain of Apache and how I solved it.
Suppose my website is at: localhost/mywebsite/test.html
The code of test.html is:
Code:

<html>
<head>
<title>Testing</title>
</head>
<body>
Testing error log of Apache server
</body>
</html>

And, whenever I accessed this site, I will get the error in error.log file of Apache, like this:
[Wed Nov 07 12:42:55 2012] [error] [client xxx.17.yyy.24] File does not exist: /htdocs
[Wed Nov 07 12:43:06 2012] [error] [client xxx.17.yyy.24] File does not exist: /htdocs
[Wed Nov 07 12:43:07 2012] [error] [client xxx.17.yyy.24] File does not exist: /htdocs

So, how can I fix this? The key is: favicon.ico
Insert one more line into my code website:
Code:

<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon" />
Now, the code of website test.html is:
Code:

<html>
<head>
<link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon" />
<title>Testing</title>
</head>
<body>
Testing error log of Apache server
</body>
</html>

OK, and don't forget put a favicon.ico file in the same folder of this page.
Now, try to open website again, I don't get the stupid error from Apache anymore.
I hope this helps you guys somehow.
Good luck.
Simon.

byeagley 11-25-2012 08:08 PM

I too was suffering this problem with a new install on a Debian box. I don't do Apache setups on a regular basis so I always end up suffering with details such as this. In my case I guessed the host was not able to resolve the host name I was using in the <VirtualHost hostname:8081> tag. When I added the fully qualified hostname to my /etc/hosts file and restarted Apache it started to work. Perhaps this will help someone else.

In my case I was just throwing something together quickly so perhaps this is not preferred method. For example, I'm doing stuff with NAT'd IPs, various hosts, multiple sites so I have not resolved how I plan to leverage DNS in all of this yet. (Pun intended!)

byeagley 11-25-2012 08:10 PM

I apologize for a less than accurate response above, but the site was blocking me from using the fully qualified name in my post. It thought I was trying to link to another site so I was forced to use the word hostname where I otherwise would have had the actual fully qualified host.domainname syntax.


All times are GMT -5. The time now is 02:48 AM.