如果它停止响应并且套接字仍在使用中,如何自动重新启动apache

Apache服务器Debian Linux x64在mysite.com和其他使用虚拟主机的网站上提供站点单声道应用程序。

有时Apache会停止响应的原因不明。 Apache error_log包含:

[Sat Jun 20 13:56:31 2015] [error] [client 90.190.33.164] File does not exist: /var/www/apple-touch- icon.png [Sat Jun 20 16:38:04 2015] [error] server reached MaxClients setting, consider raising the MaxClients setting [Sat Jun 20 17:20:11 2015] [notice] caught SIGTERM, shutting down mod-mono-server received a shutdown message [Tue Jun 23 09:20:50 2015] [error] mod_mono: connect error (Interrupted system call). File: /tmp/mod _mono_server_default mod-mono-server received a shutdown message mod-mono-server received a shutdown message mod-mono-server received a shutdown message [Tue Jun 23 09:20:54 2015] [error] Not running mod-mono-server.exe because no MonoApplications, Mono ApplicationsConfigFile or MonoApplicationConfigDir specified. [Tue Jun 23 09:20:54 2015] [notice] Apache/2.2.16 (Debian) mod_mono/2.6.3 configured -- resuming normal operations .. 

看起来像

 [Sat Jun 20 16:38:04 2015] [error] server reached MaxClients setting, consider raising the MaxClients setting 

日志文件中的消息首先出现。

之后,可能cron作业尝试下面重新启动apache,在error_log中导致消息:

 [Sat Jun 20 17:20:11 2015] [notice] caught SIGTERM, shutting down mod-mono-server received a shutdown message 

服务器在此时开始closures:access_log从6月20日17:20开始不logging任何访问

当我手动重新启动服务器时,服务器仅在[星期二23 23 09:20:50 2015]开始重新启动。 这个从上个月开始发生,每月几次。

要解决此问题,每10分钟后使用以下crontab脚本:

 wget --timeout=10 --no-verbose --tries=1 -a /var/log/wget.log -O /var/log/wgettulem.html mysite.com || /etc/init.d/apache2 restart 

如果apache停止响应,则由此脚本写入的日志文件包含

Connection timed out错误消息。

但是,Apache不重启。 尝试使用手动重新启动它

 /etc/init.d/apache2 restart 

返回Sockect正在使用错误。 ps aux显示apace正在运行。

我通过使用解决这个问题

 ps aux | grpe apache 

findappache进程号和使用

 kill 

杀死这个过程。

如何解决或find这个消息的共鸣? 如何自动执行这个过程,以便所有的apache实例都被终止,并且apache会被这个脚本自动重新启动。 如何保持Apache的响应方式?

Debian版本是6.0.4

apache2 -V返回

 Server version: Apache/2.2.16 (Debian) Server built: Feb 5 2012 21:35:42 Server's Module Magic Number: 20051115:24 Server loaded: APR 1.4.2, APR-Util 1.3.9 Compiled using: APR 1.4.2, APR-Util 1.3.9 Architecture: 64-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/etc/apache2" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="mime.types" -D SERVER_CONFIG_FILE="apache2.conf" 

包含apache2.conf

 <IfModule mpm_prefork_module> StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 150 MaxRequestsPerChild 0 </IfModule> 

如果您只是想强制重启Apache(由于任何原因),那么您应该通过R-fx Networks安装系统完整性监视器。

在许多function中 ,它可以configuration为监控您的Web服务,自动发出重启命令并发出通知。

快速安装说明:

 cd /usr/local/src wget http://www.rfxn.com/downloads/sim-current.tar.gz tar -xvf sim-current.tar.gz cd sim* ./setup -i 

继续交互式安装,为您的Web服务可执行文件定义适当的文件path。 最后一步,启用cronjob:

 /usr/local/sbin/sim -j