Question

I want to have multiple httpd services running on a CentOS box, so that if I'm developing a mod_perl script and need to restart one of them, the others can run independently. I had this setup on Windows and am migrating.

Naturally this means separate PID files. I configure mine using the PidFile directive in httpd.conf, and point the init.d script to the same place. It creates the file okay, but does not populate it with all PIDs:

$ sudo killall httpd ; sudo service httpd-dev restart
Stopping httpd: cat: /var/run/httpd/httpd-dev.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

Starting httpd:                                            [  OK  ]
$ sudo cat /var/run/httpd/httpd-dev.pid
18279
$ ps -A | grep httpd
18279 ?        00:00:00 httpd
18282 ?        00:00:00 httpd
18283 ?        00:00:00 httpd
18284 ?        00:00:00 httpd
18285 ?        00:00:00 httpd
18286 ?        00:00:00 httpd
18287 ?        00:00:00 httpd
18288 ?        00:00:00 httpd
18289 ?        00:00:00 httpd

...why might this be? Makes it hard to kill just my dev httpd procs later when there will be other httpds. Can't just use 'killall' forever...

$ httpd -v
Server version: Apache/2.2.24 (Unix)

I should note that CentOS 6.4 minimal didn't come with killproc installed, so I changed my init.d to use

kill -9 `cat ${pidfile}`

instead. I guess killproc would search out child PIDs? So I have to install python to install killproc just to use init scripts for httpd?

Was it helpful?

Solution

There are two things here:

  • Your single Apache instance might have several PIDs associated with it, depending on the type of MPM selected. However, this should not affect you, since you only need to kill the PID written into the PID file, and that process will kill all the rest of the Apache instance.

  • If you try to run several Apache instances side by side, you'll have to specify a different PID file, one for each. Then you can decide which instances you want to kill - you have to process the PID file of each instance selected. Giving the same PID file to several instances, and expecting them each to put their own PID into the same file, that'll not work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top