As mentioned, for example ubuntu sets pidfile in apache.conf this way:
The APACHE_PID_FILE environment variable is defined in /etc/apache2/envvars this way:
... and the variable sourced from envvars file in /etc/init.d/apache2 this way:
PIDFILE=`. /etc/apache2/envvars ; echo $APACHE_PID_FILE`
You mentioned CentOS - it will have probably different apache configuration hierarchy, but you have the idea where to look. The problem could be environment variable (as mentioned monit purges environment variables so unless you use envvars-like file you may have problem) or apache configuration issue.
On Jun 24, 2010, at 5:10 PM, Tong Anh Quan wrote:
On Thu, Jun 24, 2010 at 9:48 PM, Martin Pala <address@hidden>
The pidof shows pid of all matching processes - in case of apache there is one master httpd process (parent) which spawns number of child processes to handle particular requests - if apache is stopping it may take a while before they handle all pending requests and stop.
I know, obviously.
Since the pidfile doesn't exist i suppose apache is not running on your machine and only some child processes remain active (stopping) ... their parent pid will be most probably "1" (their original parent exited). You can verify apache's status for example using 'apachectl status' and also by trying to connect to the http service which should fail.
What a pity, you're wrong. I checked it before posting:
# ps -ef | grep httpd
root 21422 1 0 12:49 ? 00:00:00 /usr/sbin/httpd
apache 21424 21422 0 12:49 ? 00:01:29 /usr/sbin/httpd
apache 21425 21422 0 12:49 ? 00:02:01 /usr/sbin/httpd
apache 21426 21422 0 12:49 ? 00:01:46 /usr/sbin/httpd
apache 21427 21422 0 12:49 ? 00:03:33 /usr/sbin/httpd
apache 21428 21422 0 12:49 ? 00:02:01 /usr/sbin/httpd
apache 21429 21422 0 12:49 ? 00:01:49 /usr/sbin/httpd
apache 21431 21422 0 12:49 ? 00:02:45 /usr/sbin/httpd
apache 21432 21422 0 12:49 ? 00:00:58 /usr/sbin/httpd
apache 21443 21422 0 12:50 ? 00:02:22 /usr/sbin/httpd
apache 21444 21422 0 12:50 ? 00:01:32 /usr/sbin/httpd
apache 21445 21422 0 12:50 ? 00:01:35 /usr/sbin/httpd
and I can connect to my web page normally.
If despite missing pidfile apache is running and serving requests, then you have some problem with apache's startup script.
Until now, I have no problem.
Note that monit runs the script in "sandbox" and purges environment variables when starting the script (for security reasons). If you apache's startup depends on some variable, you will need to modify the start script to include it (apache usually uses "envvars" file which is should contain variables required for apache).
I use the Apache's default config file and it works fine when restart from command line.