# Apache startup problems [SOLVED]

## roachrider

Hi,

I'm trying to get Apache running on a recently installed Gentoo machine.

Apache emerges, starts up, and stops fine. However, the next time I go to start it, it hangs. I have to unmerge and then reemerge it before I can start it again. Here is what I have done so far:

I've gone to using almost the default Gentoo Apache config and stopped loading modules for SSL, PHP, LDAP, etc until the problem is resolved. The version and flags I am using:

```
net-www/apache-2.0.54-r31  +apache2 -debug +doc -ldap -mpm-leader -mpm-peruser +mpm-prefork -mpm-threadpool -mpm-worker -no-suexec (-selinux) -ssl -static-modules -threads 
```

The appropriate line from /etc/conf.d/apache2

```
APACHE2_OPTS="-D DEFAULT_VHOST"
```

These are the only lines I changed in the default config:

```
ServerName www.domain.com

CustomLog logs/access_log combined
```

I made no mods to /etc/apache2/vhosts.d/00_default_vhost.conf as it serves up the content of /var/www/localhost/htdocs for unmatched requests which is fine for this test.

For testing, I also added the "-e debug" option to the start line in /etc/init.d/apache2.

Now, after starting and stopping Apache once, it hangs on the second start. For example:

```

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

 * Starting apache2 ...

[Thu Dec 01 16:19:44 2005] [debug] mod_so.c(248): loaded module access_module

<snip>

[Thu Dec 01 16:19:44 2005] [debug] mod_so.c(248): loaded module include_module                                                                                        [ ok ]

server0 ~ # ps aux | grep apach

root      5401  0.2  0.3   6604  2720 ?        Ss   16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

apache    5402  0.0  0.2   6548  2668 ?        S    16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

apache    5403  0.0  0.3   6740  2752 ?        S    16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

apache    5404  0.0  0.3   6740  2752 ?        S    16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

apache    5405  0.0  0.3   6740  2752 ?        S    16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

apache    5406  0.0  0.3   6740  2752 ?        S    16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

apache    5407  0.0  0.3   6740  2752 ?        S    16:19   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

root      5409  0.0  0.0   1500   492 pts/0    S+   16:19   0:00 grep apach

server0 ~ # netstat -an | grep LISTEN | grep 80

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN

```

Here, I can connect to the server with a web browser and see the normal Apache successful install webpage.

```

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

 * Stopping apache2 ...                                                                                                                                               [ ok ]

server0 ~ # ps aux | grep apache

root      5467  0.0  0.0   1496   448 pts/0    S+   16:20   0:00 grep apache

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

 * Starting apache2 ...

[Thu Dec 01 16:20:20 2005] [debug] mod_so.c(248): loaded module access_module

<snip>

[Thu Dec 01 16:20:20 2005] [debug] mod_so.c(248): loaded module include_module                                                                                        [ ok ]

server0 ~ # ps aux | grep apach

root      5530  0.0  0.2   6544  2632 ?        Ss   16:20   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

root      5532  0.0  0.0   1496   444 pts/0    S+   16:20   0:00 grep apach

server0 ~ # netstat -an | grep LISTEN | grep 80

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN

```

Here, if I try to connect to the server with a web browser, the connection times out with no response.

```

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

 * Stopping apache2 ...

httpd (no pid file) not running                                                                                                                                       [ ok ]

server0 ~ # ps aux | grep apach

root      5687  0.0  0.2   6544  2640 ?        Ss   16:35   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -e debug -k start

root      5735  0.0  0.0   1492   444 pts/0    S+   16:36   0:00 grep apach

server0 ~ # pkill apache2

server0 ~ # tail -n 100 /var/log/apache2/error_log

[Thu Dec 01 16:19:44 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Thu Dec 01 16:19:44 2005] [debug] mod_so.c(248): loaded module access_module

<snip>

[Thu Dec 01 16:19:44 2005] [debug] mod_so.c(248): loaded module include_module

[Thu Dec 01 16:19:44 2005] [notice] Digest: generating secret for digest authentication ...

[Thu Dec 01 16:19:44 2005] [notice] Digest: done

[Thu Dec 01 16:19:44 2005] [notice] Apache configured -- resuming normal operations

[Thu Dec 01 16:20:13 2005] [notice] caught SIGTERM, shutting down

[Thu Dec 01 16:20:20 2005] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)

[Thu Dec 01 16:20:20 2005] [debug] mod_so.c(248): loaded module access_module

<snip>

[Thu Dec 01 16:20:20 2005] [debug] mod_so.c(248): loaded module include_module

[Thu Dec 01 16:20:20 2005] [notice] Digest: generating secret for digest authentication ...

```

You can see that the second time I start Apache, only one process starts instead of the normal seven. Also, the lines "Digest: done" and "Apache configured -- resuming normal operations" never appear in the log. I can see websites the first time I start Apache, but GET requests time out on the second iteration of startup. Finally, Apache isn't loading far enough to record it's PID in the /var/run/apache2.pid.

Rebooting the machine won't allow me to startup Apache successfully. Only unmerging and reemerging the package will allow one startup before this behaviour returns.

Does anyone have any ideas what could be causing this?

Thanks,

    -Aaron TaylorLast edited by roachrider on Wed Feb 22, 2006 7:34 pm; edited 1 time in total

----------

## ecosta

I had the same kind of behaviour when I had a conflict between my main httpd.conf (or is it apache2.conf now?) and one of my vhosts files.  Did you create any?

Will it work if you leave the config file as is after emerge?

You stop SSL but it tries to load a Digest:

 *Quote:*   

> [Thu Dec 01 16:20:20 2005] [notice] Digest: generating secret for digest authentication ... 

 

I am no expert but I'd go back to the original config and start from there.  Like I said, I had a simple error in config and in gave the same results.

Sorry I can't be of more help but my box is at home and I am at work  :Sad: 

Ed.

----------

## Gregs

It's a common problem.. It's described in the last paragraph of Common problems @ http://gentoo-wiki.com/Apache2_Install#Common_Problems

Check if:

```
cat /proc/sys/kernel/random/entropy_avail
```

returns a number >50. If not, you don't have enough entropy to start apache. In this case, emerge a random number generator

```
emerge rng-tools 

/etc/init.d/rngd start 

rc-update add rngd default

```

and check

```
cat /proc/sys/kernel/random/entropy_avail
```

again. Now it shoud be a much bigger number. So now you should be able to start apache properly  :Smile: 

----------

## roachrider

Gregs had it right. After emerging the rng daemon, I had enough entropy for Apache to start and generate everything.

Huge thanks for the help!

-Aaron Taylor

----------

## PaulCompton

 *Gregs wrote:*   

> 
> 
> Check if:
> 
> ```
> ...

 

Gregs, you are spot on with the tip to fix this. But > 50 wasn't enough for me. With an entropy of 130 Apache wouldn't restart - as soon as I gave the command, it went down to 1 and waited for me to do something. My server is currently pretty idle, as it is only used for internal site testing. It seems that I need an entropy of over 200 to get Apache to restart comfortably.

----------

## PaulCompton

Roachrider: please add [solved] to the subject line when your problem is solved. It makes it much easier for others searching the forums!

----------

## roachrider

Done. Sorry about that. I didn't know the procedure and will follow it in the future.

Thanks,

   -Aaron Taylor

----------

## PaulCompton

 *roachrider wrote:*   

> Done. Sorry about that. I didn't know the procedure and will follow it in the future.
> 
> 

 

Hey, as another noob, albeit one who has got a lot of help from these forums, let me say: welcome! You'll normally find answers to your questions here, and most of the people are simply great.

----------

