# Apache2 404 error /usr/htdocs [SOLVED]

## trondert

My webserver used to work, dont know when it was changed. Not that long ago since i did a apache2 restart, and it still worked. I just finished installing gallery2, and changed memeory_limit to 18M, then restartet apache2:

 *Quote:*   

> media apache2 # /etc/init.d/apache2 restart 
> 
>  * Stopping apache2 ...
> 
> [Sat May 20 00:28:48 2006] [warn] NameVirtualHost *:80 has no VirtualHos  [ ok ]
> ...

 

And i can no longer access my website.

error log gives this:

 *Quote:*   

> 
> 
> [Sat May 20 00:28:48 2006] [notice] caught SIGTERM, shutting down
> 
> [Sat May 20 00:28:51 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2) 
> ...

 

my apache2 conf:

 *Quote:*   

> tdocs# <IfDefine NNN> where NNN is the option to enable that module.
> 
> # Here are the options available in the default configuration:
> 
> #   USERDIR   Enables /~username mapping to /home/username/public_html
> ...

 

So, seems like apache wants to access the user/htdocs, but the conf seems ok. couse i want it to point to default /var/www/localhost/htdocs. And i dont use any virtaul host, only one site.

This did not help me:

http://www.gentoo.org/doc/en/apache-troubleshooting.xml#doc_chap6

Any help would be god  :Smile: Last edited by trondert on Sat May 20, 2006 1:19 pm; edited 1 time in total

----------

## ekutay

This is your startup conf not your apache configuration. Check the /etc/apache2 directory for configuration files and directories (httpd.conf, vhosts.d, conf.d ...).

----------

## trondert

thx ekutay  :Smile: 

/etc/apache2/vhost.d/00_default_vhost.conf

 *Quote:*   

> 
> 
> ### Section 3: Virtual Hosts
> 
> #
> ...

 

/etc/apache2/httpd.conf

 *Quote:*   

> #
> 
> # Gentoo VHosts
> 
> #
> ...

 

Cant't find any other ref to my "web" dir.....

----------

## ekutay

Okay, please check startup variables.

```
 ps -C apache2 --format args 
```

In case the -D DEFAULT_VHOST is missing, restart apache2 with /etc/init.d/apache2 stop and the start. Do not use reload, this will not change startup variables.

----------

## trondert

THX, but still no luck.....

 *Quote:*   

> 
> 
> media trondert # ps -C apache2 --format args
> 
> COMMAND
> ...

 

/var/log/apache2/error_log

 *Quote:*   

> 
> 
> [Sat May 20 11:41:33 2006] [notice] caught SIGTERM, shutting down
> 
> [Sat May 20 11:41:40 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)
> ...

 

----------

## ekutay

 *trondert wrote:*   

> APACHE2_OPTS="-D DEFAULT_VHOST -D USERDIR -D PHP5"

 

This is still not used by your apache as far as I can see. You have a  *Quote:*   

> <IfDefine DEFAULT_VHOST>
> 
> <VirtualHost *:80> 

  in your config, what requires the -D DEFAULT_VHOST startup parameter. In case you cannot convince apache2 to use this parameters on startup you could try to comment the  *Quote:*   

> # <IfDefine>

  rule. Don't forget to comment the closing   *Quote:*   

> # </IfDefine>

 

----------

## trondert

THX!

Fixed the root dir, but no luck for ~ dir..

----------

## ekutay

Well basically the same task, find the  *Quote:*   

> <IfDefine USERDIR> 

  and comment it out.

Note: this is actually not a fix, but a workaround. Usually these defines work lika a charm. There is something else in your setup preventing the init script from setting the needed startup parameters, e.g. -D USERDIR and -D DEFAULT_VHOSTS.   :Exclamation: 

----------

## trondert

THX again  :Smile: 

found it in httpd.conf

And now it works! So thanks for the help.

edit:

And i will see if i cant find the real error.

----------

## OolongTea

I had this problem and just solved it by finding this thread. The error occurs because APACHE2_OPTS does not get loaded into the environment, and this occurs because Apache is being started directly from /sbin/apache2, as opposed to using the startup script /etc/conf.d/apache2. 

Very old post but I am just writing this to help anyone who might come across this thread via Google, as I did.

----------

## firsttry

Had this same problem - couldn't work out what it was until I realised I had two APACHE_OPTS lines in my /etc/conf.d/apache2 file. Removed one and apache finally worked!

----------

## EvilGod

After commenting the USERDIR also it didnt' work for me. and getting same /usr/htdocs not found error. .. how do i solve this problem now ?

<IfDefine USERDIR>

----------

## tmchesser

I realize this thread hasn't had a response on it for a while.  I was referred to it from Google, while searching for the

```
File does not exist: /usr/htdocs
```

error message.  Allow me to add my findings, in the hopes that future finders of this thread will have more assistance.

I'm using multiple sites on one server, all using <VirtuaHost 192.168.1.2:80></VirtualHost> blocks.  My /etc/apache2/vhosts.d/00_default_vhost.conf file has 

```
NameVirtualHost 192.168.1.2:80
```

in it, so that Apache will know that there will be VirtualHost entries on that IP:Port combination.  This got rid of this error in my logfile:

```
[warn] VirtualHost 192.168.1.2:80 overlaps with VirtualHost 192.168.1.2:80, the first has precedence, perhaps you need a NameVirtualHost directive
```

The problem, however, was that ONE of my VirtualHosts was working, but two others were not.  If I tried accessing something off http://localhost/, I got the "/usr/htdocs" error message in /var/log/apache2/errorlog and a "404 error" in accesslog and my browser.  For one of my VirtualHosts, I got that error message.  Another VirtualHost worked just fine.  I compared the .conf files for everything, and was at a total loss for why it wouldn't work.

The /var/log/apache2/accesslog file gave the critical clue.  I had set NameVirtualHost to 192.168.1.2:80.  The VirtualHost which worked showed that IP address in the accesslog.  The VirtualHosts which DID NOT work showed "127.0.0.1" in the access log.  Since I was using an explicit IP address and port, instead of "*:80" or "*:*" it didn't know how to respond to a request to localhost.  Another thread that I found while researching the problem showed that /usr/htdocs is hardcoded into the Apache source code as a "last resort" place to look if it didn't know how to handle the request.  That was why I couldn't find "/usr/htdocs" anywhere in any of my config files, and I didn't even have a "/usr/htdocs" on my machine.

Lesson:  when troubleshooting 404 errors LEARN TO READ THE ACCESSLOG! I had entries in my /etc/hosts files which pointed the non-working URL domains over to 127.0.0.1.  Once I removed them, and they all resolved to 192.168.1.2, all of them worked without a hitch.

It took me a full day of work to finally straighten this out.  Here's hoping it allows somebody else to get to the bottom of this a lot faster, in the future.

Regards,

Tony Chesser

----------

## Denver1980

Just to add my little trial & error.

I changed my <VirtualHost thisvirthost> tag to <VirtualHost thisvirthost_prd> for clarity reason.

After the modification, all my requests to that virtual host where getting the 404 error and I had 

```
File does not exist: /usr/htdocs
```

 in my error_log file.

When i finally RTFM http://httpd.apache.org/docs/current/mod/core.html#virtualhost I figured out that the name used by the VirtualHost bracket needed to be in /etc/hosts.

Added thisvirthost_prd to my hosts file for the correct IP adresse solved my problem.

/etc/apache2/vhosts.d/mycnfg.conf

```
<IfDefine HOST_PROD>

NameVirtualHost thisvirthost_prd

Listen 192.168.0.120:80

<VirtualHost thisvirthost_prd>

        ServerAdmin moi@quelque.part

        ServerName myname.dyndns.org

        DocumentRoot /var/www/html

        <Directory "/var/www/">

                Options FollowSymLinks MultiViews

                AllowOverride All

                Order allow,deny

                Allow from all

        </Directory>

</VirtualHost>

</IfDefine>
```

/etc/conf.d/apache2

```
APACHE2_OPTS="-D HOST_PROD -D SSL -D PHP5"
```

/etc/hosts

```
192.168.0.120  myname.dyndns.org       thisvirthost_prd
```

Really hopes this will save someone's time  :Very Happy: 

Vincent

----------

