# Apache problem (solved)

## zeuz

Edit:

Solved it by adding "Listen 80" in the default_vhost file.   :Embarassed: 

Hi!  :Smile: 

Apache won't work since I ran my last update. 

I'm having the same problem as this guy: https://forums.gentoo.org/viewtopic-t-608381-highlight-making+http+connection+localhost.html

I haven't touched the /etc/hosts file. The apache error log doesn't say anything either.

Apache version:

```

Server version: Apache/2.2.6 (Unix)

Server built:   Nov  5 2007 18:38:19

```

/etc/hosts:

```

127.0.0.1 devil.***.com devil localhost

```

/etc/init.d/apache status:

```

Looking up localhost

Making HTTP connection to localhost

Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://localhost/server-status

```

Thanks.Last edited by zeuz on Thu Nov 22, 2007 12:38 pm; edited 1 time in total

----------

## sergioag

Hi

Could you try:  *Quote:*   

> ping localhost

  to see if it resolves to 127.0.0.1?

Sergio

----------

## zeuz

Yep  :Smile: 

```
stefan@devil ~ $ ping localhost

PING devil.***.com (127.0.0.1) 56(84) bytes of data.

64 bytes from devil.***.com (127.0.0.1): icmp_seq=1 ttl=64 time=0.115 ms

64 bytes from devil.***.com (127.0.0.1): icmp_seq=2 ttl=64 time=0.137 ms

```

----------

## sergioag

Hi

Have you tested to see if Apache is listening to all hosts or at least to localhost? Try this:

```
netstat -ltp
```

You should have something like this (among other lines):

```
Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   

tcp        0      0 *:http                  *:*                     LISTEN      1601/apache2 
```

If you have something different to *:http or locahost:http, it may be the source of the problen. In that case, you must edit your /etc/apache2/vhosts.d/00_default_vhost.conf file to alter the "Listen " directive. If there's something like Listen 80, then it's ok. But if there an ip like in Listen x.x.x.x:80 then it will not work for the purpose of this problem.

Hope this helps.

Sergio

----------

## zeuz

I only have https, which works.

```
tcp        0      0 *:https                 *:*                     LISTEN      29066/apache2  
```

I haven't changed my vhost conf file anything but I have "NameVirtualHost *:80" in it.

----------

## sergioag

Hi

Actually, that's the problem: apache is not listening to port 80 (http).  Edit your /etc/conf.d/apache2 file making APACHE2_OPTS like this:

```
APACHE2_OPTS="-D DEFAULT_VHOST -D SSL_DEFAULT_VHOST -D PHP5"
```

The key part of this line is DEFAULT_VHOST, which you probably don't have. If you don't want to use plain http, but https only, you can edit your /etc/init.d/apache2 around lines 111 and 118 and replace http with https.

Sergio

----------

## zeuz

This probably happened when I ran etc-update. I didn't even have PHP in my APACHE_OPTS var.

Current:

```
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D SUEXEC"
```

Got this error with yours:

```
* Starting apache2 ...

no listening sockets available, shutting down

Unable to open logs                     
```

----------

## sergioag

Hi

Can you post your /etc/apache2/vhosts.d/00_default_vhost.conf file? Please note that i assume you haven't modified /etc/apache2/httpd.conf in a way that makes apache not load files in /etc/apache2/vhosts.d.

Sergio

----------

## zeuz

I've tried using the example conf but it didn't make any difference so I went back to my old one:

```
NameVirtualHost *:80

<IfDefine DEFAULT_VHOST>

<VirtualHost *:80>

    DocumentRoot "/var/www/localhost/public_html"

    <Directory "/var/www/localhost/public_html">

        Options Indexes FollowSymLinks

        AllowOverride None

        Order allow,deny

        Allow from all

    </Directory>

    <IfModule peruser.c>

        ServerEnvironment apache apache

        MinSpareProcessors 4

        MaxProcessors 20

    </IfModule>

    <IfModule itk.c>

        AssignUserID apache apache

        MaxClientsVHost 50

    </IfModule>

</VirtualHost>

</IfDefine>

```

Edit:

I have some other vhosts too, but they have always worked and looks the same.

I haven't modified my httpd.conf but heres my last lines:

```
# Virtual-host support

#

# Gentoo has made using virtual-hosts easy. In /etc/apache2/vhosts.d/ we

# include a default vhost (enabled by adding -D DEFAULT_VHOST to

# APACHE2_OPTS in /etc/conf.d/apache2).

Include /etc/apache2/vhosts.d/*.conf

# vim: ts=4 filetype=apache
```

Seems to be ok? How can the https work but not the http?

----------

## zeuz

Also tried to unemerge and emerge apache but with no luck.  :Sad: 

----------

## giant

Listen 80

in the default vhost and the -D DEFAULT_VHOSt did the trick for me !

Looks like maybe the httpd.conf got changed ?

Cheers -

GianT

----------

