# [SOLVED-reinstalled] Apache cannot find listening socket

## SxN

Hi,

Cannot start Apache; tried

```
/etc/init.d/apache2 start
```

and also directly:

```
/usr/sbin/apache2

no listening sockets available, shutting down

Unable to open logs
```

There is no indication in logs of what can be wrong (maybe because it couldn't open them?). I ensured that all log files in /var/log/apache2 are rw-rw-rw-, but it made no difference.

Other few things:

```
grep -w 80 /etc/services

http         80/tcp         www www-http      # World Wide Web HTTP

http         80/udp         www www-http

/usr/sbin/apache2 -t

Syntax OK
```

What should I try to go over this one?

Thanks,

SxNLast edited by SxN on Wed Mar 19, 2014 4:29 pm; edited 1 time in total

----------

## gotyaoi

Post the output of

```
netstat -nlpt
```

please. Also, what do you have apache set to listen on in httpd.conf, ie. post any "Listen" directives in there or in Include'd conf files.

----------

## SxN

```
# netstat -nlpt

Active Internet connections (only servers)

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

tcp        0      0 0.0.0.0:6000          0.0.0.0:*               LISTEN        25770/X

# cd /

# grep -r "Listen" *

... skipping comments, binaries etc ...

etc/apache2/vhosts.d/00_default_ssl_vhost.conf:Listen 443

etc/apache2/vhosts.d/00_default_vhost.conf:Listen 80
```

----------

## gotyaoi

Hmm, backing up for a moment then, you are trying to start apache as root, yes? Not as a normal user?

----------

## SxN

Yes, root

----------

## SxN

Being an Apache novice, it took me a while to understand that I was missing /etc/apache2/apache2.conf. Now it is there, though am not sure it is right. Or it may be something else wrong, because:

- when starting, Apache complains that it could not determine the servers fully qualified domain name, although my last line in that configuration file states 

```
ServerName=localhost
```

- then it reports that it fails to start

- despite that, it seems to work at some level, servicing browsers

- there is a twist though: the service provided is not correct. My experimental index.html file looks like this 

```
<html><body>Hello</body></html>
```

Browsers show this:

```
<html><body>Hello</body></html>
```

Had a look with Firebug in what is delivered to the browser, and here is the code:

```
<html>

<head>

<link title="Wrap Long Lines" href="resource://gre-resources/plaintext.css" type="text/css" rel="alternate stylesheet">

</head>

<body>

<pre><html><body>Hello</body></html> </pre>

</body>

</html>
```

My original file content is treated as text!

Where should I look to remedy my situation?

Thanks

----------

## 666threesixes666

remove pre tags....

kazam@kazam [ ~ ] $ cat /var/www/localhost/htdocs/index.html

<head>

<link rel="stylesheet" type="text/css" href="index.css">

</head>

<html><body><h1>It works!</h1></body></html>

my index.css is right next to index.html

remove ServerName=localhost /etc/hosts determines that

root@vegas [ ~ ]# service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using thecpamatrix.com for ServerName

                                                           [  OK  ]

#162.248.5.86 thecpamatrix.com www.thecpamatrix  thecpamatrix www.thecpamatrix.com

remove # &

root@vegas [ ~ ]# service httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd:                                            [  OK  ]

welcome, have a good day & good luck!   :Very Happy: 

----------

## Hu

 *SxN wrote:*   

> Browsers show this:
> 
> ```
> <html><body>Hello</body></html>
> ```
> ...

 Firebug reports weird things when you try to analyze a text/plain document as though it were text/html.  I suspect that Firefox internally converted it to an appropriately wrapped text/html document, which is why you have the reference to a resource:// object.

Your problem is that the server is reporting a MIME type of text/plain instead of text/html.  I do not know why, but hopefully this points you in the right direction for further research.

----------

## SxN

666 - I don't have a <pre> in my original file; it is inserted automatically

Hu - I think the same, and am pouring through the documentation of every module, to try to determine if I'm missing one

Meanwhile, by tweaking with the configuration files, I got rid of all the error messages, except "apache failed to start" (but in fact, it is started). There is, for sure, some issue that Apache tries to go around, shown by the long loading time.

I also subscribed to an Apache forum, awaiting moderator approval to join and ask there for some pointers too.

Thanks for your suggestions, and let them come,

SxN

----------

## SxN

I created a little .htaccess beside index.html, with the following content:

```
AddHandler text/html .html   
```

Trying now to access index.html, I got a 500 Internal Server Error (in the form of an HTML source code). A quick check in log gives this:

```
Invalid command 'AddHandler', perhaps misspelled or defined by a module not included in the server configuration.
```

Well, httpd.conf has this line:

```
LoadModule mime_module modules/mod_mime.so
```

Earlier I tried to use AddType instead of AddHandler, with the same results.

Bogs my mind, what may be going on?

Thanks

----------

## 666threesixes666

<IfModule mod_garbage.c>

SomeSexy garbage directive

</IfModule>

 :Twisted Evil:   good luck on thy quest!

----------

## SxN

Fixed the problem:

```
emerge --unmerge apache
```

then downloaded the latest from www.apache.org and installed that. 10 or 15 minutes later I was on  :Smile: )

SxN

----------

