# apache no restart correctly (SEMI-SOLVED)

## nandelbosc

Hi!

I'm using apache 2.0.58-r2 and when I restart it more than one time I cannot restart anymore

```
vito ~ # /etc/init.d/apache2 restart

 * Stopping apache2 ...                                                                                               [ ok ]

 * Starting apache2 ...                                                                                               [ ok ]

vito ~ # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito ~ # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

...

```

then I need to kill it manually...

```

vito ~ # ps aux  | grep apache

root     13847  0.0  0.1  51140  2164 ?        Ss   02:22   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf -k start

root     13997  0.0  0.0   2608   512 pts/2    R+   02:24   0:00 grep apache

vito ~ # killall apache

apache: no process killed

vito ~ # killall apache2

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

 * WARNING:  "apache2" has already been started.

vito ~ # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito ~ # killall apache2

apache2: no process killed

vito ~ # killall apache2

apache2: no process killed

vito ~ # /etc/init.d/apache2 zap

 * Manually resetting apache2 to stopped state.

vito ~ # /etc/init.d/apache2 restart

 * Starting apache2 ...                                                                                               [ ok ]

vito ~ # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

...
```

I have a new install, with default apache.conf.Last edited by nandelbosc on Mon Nov 27, 2006 11:24 pm; edited 1 time in total

----------

## Hagar

restart doesn't work well, it doesn't give apache enough time to close.

If you really want a shutdown->startup restart use:

/etc/init.d/apache2 stop

wait for it to really exit (3 sec works for my system)

/etc/init.d/apache2 start

If you only need a configuration reload you can use:

/etc/init.d/apache2 reload

----------

## nandelbosc

not works at all...

```

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...                                                       [ ok ]

vito marc # /etc/init.d/apache2 reload

 * Doing a graceful restart of apache2 ...

No /usr/sbin/apache2 found running; none killed.                              [ !! ]

vito marc # /etc/init.d/apache2 reload

 * Doing a graceful restart of apache2 ...

No /usr/sbin/apache2 found running; none killed.                              [ !! ]

vito marc # /etc/init.d/apache2 start

 * WARNING:  "apache2" has already been started.

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                              [ !! ]

vito marc # killall apache2

vito marc # /etc/init.d/apache2 zap

 * Manually resetting apache2 to stopped state.

vito marc # killall apache2

apache2: no process killed

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...                                                       [ ok ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                              [ !! ]

```

----------

## nandelbosc

and...

```
vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...                                                       [ ok ]

wait for 5-6 seconds

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                              [ !! ]

wait for 5-6 seconds

vito marc # /etc/init.d/apache2 start

 * WARNING:  "apache2" has already been started.

```

----------

## selig

On my box it sometimes takes a couple of "apache stop" commands to actually stop the apache. If this does not work, check if the PID file gets created correctly (it should be set in your httpd.conf, and usually located in /var/run).

----------

## nandelbosc

more or less I have taked the control to start/stop apache, but there is another BIG problem...

apache serves pages really slowly!

What's happening with my new server? It's an AMD64 3500+ with 2GB of RAM, with a new clean gentoo installation.

There is my emerge info:

```
vito marc # emerge --info

Portage 2.1.1-r2 (default-linux/amd64/2006.1/server, gcc-3.4.4, glibc-2.3.5-r2, 2.6.18-gentoo-r3 x86_64)

=================================================================

System uname: 2.6.18-gentoo-r3 x86_64 AMD Athlon(tm) 64 Processor 3500+

Gentoo Base System version 1.6.14

Last Sync: Mon, 27 Nov 2006 01:00:01 +0000

app-admin/eselect-compiler: [Not Present]

dev-java/java-config: [Not Present]

dev-lang/python:     2.4.2

dev-python/pycrypto: 2.0.1-r5

dev-util/ccache:     [Not Present]

dev-util/confcache:  [Not Present]

sys-apps/sandbox:    1.2.17

sys-devel/autoconf:  2.13, 2.59-r6

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1

sys-devel/binutils:  2.16.1-r3

sys-devel/gcc-config: 1.3.12-r6

sys-devel/libtool:   1.5.22

virtual/os-headers:  2.6.11-r2

ACCEPT_KEYWORDS="amd64"

AUTOCLEAN="yes"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=k8 -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /var/bind"

CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"

CXXFLAGS="-march=k8 -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"

GENTOO_MIRRORS="http://trumpetti.atm.tut.fi/gentoo/ ftp://trumpetti.atm.tut.fi/gentoo/ http://gentoo.modulix.net/gentoo/ http://ftp.club-internet.fr/pub/mirrors/gentoo ftp://gentoo.imj.fr/pub/gentoo/ ftp://ftp.tu-clausthal.de/pub/linux/gentoo/ ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo http://ftp.snt.utwente.nl/pub/os/linux/gentoo ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo http://linuv.uv.es/mirror/gentoo/ "

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="amd64 amuled apache2 apic berkdb calendar clflush cli cmov cracklib crypt cx8 de dlloader dri elibc_glibc exif extensions ffmpeg fortran fpu ftp fxsr fxsr_opt gd gdbm gpm iconv imagemagick imap input_devices_evdev input_devices_keyboard input_devices_mouse ipv6 isdnlog jpeg jpeg2k kernel_linux lahf_lm libclamav libg++ lm maildir mailwrapper mca mce mpeg msr mtrr mysql ncurses network nls nptl nptlonly nx pae pam pat pcre perl pge php png pni ppds pppd pse pse36 qmail reflection remote samba sasl sep session snmp spamassassin spl sqlite ssl stats syscall tcpd tiff tsc udev unicode unzip userland_GNU vhosts video_cards_apm video_cards_ark video_cards_ati video_cards_chips video_cards_cirrus video_cards_cyrix video_cards_dummy video_cards_fbdev video_cards_glint video_cards_i128 video_cards_i810 video_cards_mga video_cards_neomagic video_cards_nv video_cards_rendition video_cards_s3 video_cards_s3virge video_cards_savage video_cards_siliconmotion video_cards_sis video_cards_sisusb video_cards_tdfx video_cards_tga video_cards_trident video_cards_tseng video_cards_v4l video_cards_vesa video_cards_vga video_cards_via video_cards_vmware video_cards_voodoo vme xml xorg zip zlib zlib2"

Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY

```

----------

## nandelbosc

Hi,

I wrote another post in Network and Security, and i have no answer... https://forums.gentoo.org/viewtopic-t-519663.html

I have two problems with apache:

1.- don't restart properly

2.- serve pages very slowly

can anyone help me?

----------

## nixnut

No cross-posting please. Read the forum guidelines.

Any messages in the log files in /var/log?

----------

## Hagar

What does it serve?

If you use some form of scripting, is that functioning properly?

Is the rest of your system *healthy* ?

----------

## nandelbosc

 *Quote:*   

> No cross-posting please. Read the forum guidelines. 

 

Ok, sorry!   :Embarassed: 

 *Quote:*   

> What does it serve? 

 

Sorry, i don't know if I understand correctly... Serve web pages, for the moment apache test page   :Wink: 

 *Quote:*   

> If you use some form of scripting, is that functioning properly? 

 

No, I don't use any special script.

 *Quote:*   

> Is the rest of your system *healthy* ?

 

Totally! It's a new clean install (of gentoo and apache).

I retried the process...

```
vito marc # /etc/init.d/apache2 restart

 * Stopping apache2 ...                                                                                               [ ok ]

 * Starting apache2 ...

[Mon Nov 27 20:15:24 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

vito marc # /etc/init.d/apache2 restart

 * Stopping apache2 ...                                                                                               [ ok ]

 * Starting apache2 ...

[Mon Nov 27 20:15:26 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

vito marc # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # ls /var/run/

cgisock             mysqld/             openldap/           snort_eth2.pid      syslog-ng.pid

console/            named/              random-seed         sshd.pid            usb/

cron.pid            ntpd.pid            samba/              svc-started-mysqld  utmp

vito marc # /etc/init.d/apache2 start

 * WARNING:  "apache2" has already been started.

vito marc # /etc/init.d/apache2 start

 * WARNING:  "apache2" has already been started.

```

As you can look, after 2 restarts don't start anymore. If I try to stop, seems apache it's started, but no pid file in /var/run/

 *Quote:*   

>  Any messages in the log files in /var/log?

 

logs:

In /var/log/apache2/access_log i can't see nothing special. The same for /var/log/apache2/error_log.

In /var/log/apache2/startuperror.log:Syntax OK

```
...

Syntax OK

Syntax OK

(98)Address already in use: make_sock: could not bind to address 192.168.10.1:80

no listening sockets available, shutting down

Unable to open logs

Syntax OK

(98)Address already in use: make_sock: could not bind to address 192.168.10.1:80

no listening sockets available, shutting down

Unable to open logs
```

the only way to start apache again:

```
vito marc # /etc/init.d/apache2 start

 * WARNING:  "apache2" has already been started.

vito marc # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 zap

 * Manually resetting apache2 to stopped state.

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 20:23:44 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!

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

no listening sockets available, shutting down

Unable to open logs                                                                                                   [ !! ]

vito marc # killall apache

apache: no process killed

vito marc # killall apache2

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 20:23:57 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

```

----------

## Hagar

That log says apache is still running when it's restarted.

Like I said in my first post, do not use restart !

Use stop and start, and wait at least 10 sec between those commands.

Your server has a hard time starting/stopping apache2.

The init script isn't as fool proof as it should be (for you anyway)

So give it time, apache *requires* time to shut down.

Onto the next issue.

You seem to have configured an ssl host, does apache accept the ssl certificates for that host?

Is your harddrive functioning properly? (dma is on etc. how is/are it/they configured, IDE or SATA, raid?)

----------

## nandelbosc

 *Quote:*   

> That log says apache is still running when it's restarted. 
> 
> Like I said in my first post, do not use restart !

 

Have you reason, But I tried  that and...

```

vito marc # /etc/init.d/apache2 status

 * status:  started

```

10 second later...

```

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...                                                                                               [ ok ]

```

10 second later...

```

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 21:35:35 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

```

10 second later...

```

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...                                                                                               [ ok ]

```

10 seconds later

```

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 21:35:55 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

```

By now all it's ok, but... 10 seconds later....

```

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 start

 * WARNING:  "apache2" has already been started.

vito marc # /etc/init.d/apache2 restart

 * Stopping apache2 ...

No /usr/sbin/apache2 found running; none killed.                                                                      [ !! ]

vito marc # /etc/init.d/apache2 zap

 * Manually resetting apache2 to stopped state.

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 21:36:36 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!

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

no listening sockets available, shutting down

Unable to open logs                                                                                                   [ !! ]

```

Always with a 10 second pause between start/stop operations.

I need to kill apache manually...

```

vito marc # killall apache2

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 21:36:45 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

```

 *Quote:*   

> Onto the next issue. 
> 
> You seem to have configured an ssl host, does apache accept the ssl certificates for that host? 

 

Yes. And I tried to disable this SSL service, but I have the same results

 *Quote:*   

> Is your harddrive functioning properly? (dma is on etc. how is/are it/they configured, IDE or SATA, raid?)

 

My root partition it's on sda3 (SATA) and /var/www it's on sda5 (same SATA disk).

The hard it's relatively new.

```
vito marc # hdparm /dev/sda

/dev/sda:

 IO_support   =  0 (default 16-bit)

 readonly     =  0 (off)

 readahead    = 256 (on)

 geometry     = 24321/255/63, sectors = 200049647616, start = 0

```

----------

## nandelbosc

By now, i can restart apache succefully 4 times with a high time between start / stop. It's normal?

I put (semi-solved) to the top post.

```
vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 23:39:13 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...                                                                                               [ ok ]

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 23:56:28 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...                                                                                               [ ok ]

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Mon Nov 27 23:59:46 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]

vito marc # /etc/init.d/apache2 stop

 * Stopping apache2 ...                                                                                               [ ok ]

vito marc # /etc/init.d/apache2 start

 * Starting apache2 ...

[Tue Nov 28 00:22:08 2006] [error] (EAI 2)Name or service not known: Cannot resolve host name *.443 --- ignoring!     [ ok ]
```

----------

## COiN3D

I have exactly the same problem. 

uname -a:

```
Linux h706877 2.6.22-gentoo-r2 #1 Tue Aug 21 09:22:20 CEST 2007 x86_64 AMD Opteron(tm) Processor 146 AuthenticAMD GNU/Linux
```

The problem:

```
# /etc/init.d/apache2 stop

 * Stopping apache2 ...                                                   [ ok ]
```

Waiting 10 seconds..

```
# ps aux | grep -ir "apache"

root     14970  0.0  0.9 176760 10116 ?        Ss   Mar06   0:00 /usr/sbin/apache2 -D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf -E /var/log/apache2/startuperror.log -k start

apache   14971  0.0  0.0      0     0 ?        Z    Mar06   0:00 [apache2] <defunct>
```

I've to kill apache2 with "killall -9 apache2", otherwise I'm not able to start it again. As already said, this only happens when running Apache with PHP5.

----------

## nandelbosc

Finally I arrived at this conclusion:

 - after apache restart, it need a few secons before restart for second time

 - after second consecutive restart, apache needs more than a minute before next restart

I can help much more ;-(

----------

## Januszzz

Hmm,

I had the same problem, but it was easy to solve it.

I was surprised with this line in /etc/init.d/apache2:

```
/sbin/start-stop-daemon --stop --retry -TERM/5/-TERM/5/-KILL/5 --exec 

${APACHE2} --pidfile /var/run/apache2.pid
```

Hard coded pid file even when one can set pid in config file?

I modified /etc/apache/httpd.conf to include:

```
PidFile /var/run/apache2.pid
```

instead of mine previous setting (from wayyyyyy too old config):

```
PidFile /var/run/httpd.pid
```

That way init script reflects real pid file location. Instead, I could also change init file to reflect it, but it is not so wise. And I guess commenting pid file would also put the pid file in default location, so the script should be right also.

Now /etc/init.d/apache2 restart goes fine.

Solved?

----------

