# [apache] Stops working after exactly 5 times reload/revoot

## SA007

I have in my opinion a very weird problem.

I'm running apache (2.0.58-r2) with praticly standard config (servername etc changed and a couple of rewriterules, but even if a remove those, still no responce).

When I start my gentoo server apache loads perfect, no errors, runs fine.

Apache reboot, no problem, but after exacly 5 apache boots it fails.

Still no errors, but only one apache process, and it does not respond to any requests...

Well, it does accept connections, but it does not give any reply at all...

When I run apache in debug mode (compiled with use=debug, not deamonized, loglevel debug) no errors, none in error log, nothing is added to the access log, nothing...

When I restart in this condition is says it quits with [ ok ] (with the message: no pid file), but doesn't start giving the error "port 443 allready in use).

ps aux shows one running apache (in S+ state), if I kill it, apache start with [ ok ] again, but still does not respond, only one process, etc...

Anyone any idea of what could be wrong here, i'm looking for more than a week, to no avail...

----------

## daemonflower

 *SA007 wrote:*   

> When I restart in this condition is says it quits with [ ok ] (with the message: no pid file), but doesn't start giving the error "port 443 allready in use).

 Do you intend to run a https server, or just http? If not you could disable the mod_ssl configuration in /etc/conf.d/apache2 and see if that changes something. If not, I suggest progressively simplifying the configuration, loading ever less modules, until you arrived at the barest minimum. If the error still persists then, well, I don't know either.

Also I'd try a "ldd /usr/sbin/apache2", maybe it depends on a nonexistent library due to a system upgrade.

----------

## SA007

The is apsolutely no problem with apache or its config, it runs completly without problems, but it stops working after 5 reboots, but functions again after a system reboot... Does no one read the OP ore something...?

And yes, i intend to run SSL

----------

## daemonflower

Man, if you want to debug a complicated system, you whittle it down to the bare minimum successively to find out what causes the problem. It's common sense. Apache is a complex system, so there. I don't have any other advice for you but to debug it.

Also, there is no such thing as an "apache reboot". It's either reload (keeping apache running, but rereading the configuration) or restart (terminating the server process and starting it up again). Your OP isn't clear as to what you do.

----------

## Makido

Same problem here...

Reload the configs "apache2 reload" or restart it with "apache2 restart" fails after some times...

"apache not startet" but it runs! so, I must kill it manually and start it again (for config reload)!

I think there's a big bug in the init-script!

```

sf ~ # ps x | grep apache

15468 ?        Ss     0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -D PHP4 -D USERDIR -D SSL -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start

16475 pts/6    R+     0:00 grep --colour=auto apache

sf ~ # /etc/init.d/apache2 configtest

 * Checking Apache Configuration ...                                                                                   [ ok ]

sf ~ # /etc/init.d/apache2 status

 * status:  stopped

sf ~ # /etc/init.d/apache2 stop

 * WARNING:  apache2 has not yet been started.

```

...our website works fine!  :Wink: 

Regards,

Maik

----------

## Makido

News:

```

sf ~ # /etc/init.d/apache2 start

 * Starting apache2 ...                                                                                                [ ok ]

sf ~ # /etc/init.d/apache2 reload

 * Reloading apache2 ...                                                                                               [ ok ]

sf ~ # /etc/init.d/apache2 reload

 * Reloading apache2 ...                                                                                               [ ok ]

sf ~ # /etc/init.d/apache2 reload

 * Reloading apache2 ...

httpd not running, trying to start                                                                                     [ ok ]

sf ~ # /etc/init.d/apache2 reload

 * Reloading apache2 ...

httpd not running, trying to start

```

Is there a fix out there?

----------

## JC99

I have the same problem, after several reboots it doesn't work and I have to restart my computer, then it loads up fine. No idea why?

----------

## martinmuc

Hi, i have the same problem here:

mail2 apache2 # /etc/init.d/apache2 restart

 * Starting apache2 ...                                                                                                                                [ ok ]

mail2 apache2 # /etc/init.d/apache2 restart

 * Stopping apache2 ...                                                                                                                                [ ok ]

 * Starting apache2 ...                                                                                                                                [ ok ]

mail2 apache2 # /etc/init.d/apache2 restart

 * Stopping apache2 ...

httpd (no pid file) not running                                                                                                                        [ ok ]

 * Starting apache2 ...

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443

no listening sockets available, shutting down

Unable to open logs               

i do the restarts after approx. a minute , and i tried to restart after 1-2 hours, same problem... 

mail2 apache2 # ps aux |grep apache2

root     20316  0.0  0.5  15796  6008 ?        Ss   12:53   0:00 /usr/sbin/apache2 -D PHP5 -D SSL -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -k start

root     20463  0.0  0.0   1524   488 pts/0    S+   12:54   0:00 grep --colour=auto apache2

If i kill the last apache process, then apache will restart again

I have 

CHOST="i686-pc-linux-gnu"

CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j2"

and my system is up to date (emerge says nothing to do  :Smile:  )

What can i check/do, that it will work again?

Can i deliver some more information to track this down?

regards,

Martin

----------

## llongi

I'll take a guess... Not enough entropy. Both mod_digest and, if used, mod_ssl need entropy from /dev/random on each start of apache, if entropy isn't replenished (which may happen, especially on headless boxes), after a few restarts there won't be enough and the start will hang, waiting on entropy.

Quick and correct fix:

```
emerge sys-apps/rng-tools && rc-update add rngd default && /etc/init.d/rngd start
```

That's a entropy-gathering daemon that will take care of replenishing /dev/random when it gets low.  :Wink: 

----------

## martinmuc

Yeah this works!!!   :Very Happy: 

Thanks for helping  :Smile: 

But one Question do i have:

What do you mean with "headless box"?  :Smile: 

regards 

Martin

----------

## llongi

 *martinmuc wrote:*   

> But one Question do i have:
> 
> What do you mean with "headless box"? 

 

Something like a server, with no monitor, keyboard and mouse attached, and thus with no X running or users using desktop applications. Most of the entropy by default comes from user input, so you tend to have more of it on systems with people using X & assorted apps.

----------

## petterg

I ran into similar problem. However my solution was slightly different. Chtekk gave me the idea - that the problem was caused by problems with random number generation. What I did to solve this was to change the kernel config:

```

CONFIG_HW_RANDOM=y

```

----------

## Janne Pikkarainen

CONFIG_HW_RANDOM is a nice solution, if your hardware (drivers) just support it.  :Smile: 

Switching randomness generation from /dev/random to /dev/urandom is also a solution - for several packages that can be done with urandom USE flag. But yes, I personally use rngd as well. One example of very entropy hungry daemon is Cyrus IMAP server's pop3 daemon...

----------

## RDWest2005

 *CHTEKK wrote:*   

> I'll take a guess... Not enough entropy. Both mod_digest and, if used, mod_ssl need entropy from /dev/random on each start of apache, if entropy isn't replenished (which may happen, especially on headless boxes), after a few restarts there won't be enough and the start will hang, waiting on entropy.
> 
> Quick and correct fix:
> 
> ```
> ...

 

I been working with apache for almost 11 years and was completely about to explode...

Thank GOD! for developers !

Thanks,

It fixed mine too..

~RD

----------

