我已经和Apache合作了8年多了,但现在我面临严重的问题,到目前为止我还找不到互联网上的解决scheme。
我在带有Service Pack 1的Windows 2008 R2 64位上运行Apache 2.2.15 32位。我总是使用32位Apache,因为我的CGI代码(exe文件)是32位。
电脑有一个3.10 GHz的处理器和16GB的RAM。 服务器负载总是非常低。 访问日志显示问题发生时的正常请求量。
自从几个月前的安装以来,一切正常,但现在我的Apache停止工作,我不知道如何解决这个问题。
几周之后,我没有改变任何configuration,但突然Apache停止服务的HTTP响应。 所有请求都会超时。 从实际意义上讲,我的网站是离线的。
通过使用Windows事件查看器,当Apache停止工作时,我发现了一个错误日志。 这是错误事件:
Log Name: Application Source: Application Error Date: 6/28/2016 8:08:33 PM Event ID: 1000 Task Category: (100) Level: Error Keywords: Classic User: N/A Computer: PictureToPeople Description: Faulting application name: httpd.exe, version: 2.2.15.0, time stamp: 0x4b8fed95 Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp: 0x4ce7ba58 Exception code: 0xc0000005 Fault offset: 0x00037188 Faulting process id: 0xbbc Faulting application start time: 0x01d1cdfef0f8148c Faulting application path: C:\Apache2.2\bin\httpd.exe Faulting module path: C:\Windows\SysWOW64\ntdll.dll Report Id: 3c1e0a43-3d85-11e6-aad3-001e8cf18221 Event Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Application Error" /> <EventID Qualifiers="0">1000</EventID> <Level>2</Level> <Task>100</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2016-06-28T23:08:33.000000000Z" /> <EventRecordID>693</EventRecordID> <Channel>Application</Channel> <Computer>PictureToPeople</Computer> <Security /> </System> <EventData> <Data>httpd.exe</Data> <Data>2.2.15.0</Data> <Data>4b8fed95</Data> <Data>ntdll.dll</Data> <Data>6.1.7601.17514</Data> <Data>4ce7ba58</Data> <Data>c0000005</Data> <Data>00037188</Data> <Data>bbc</Data> <Data>01d1cdfef0f8148c</Data> <Data>C:\Apache2.2\bin\httpd.exe</Data> <Data>C:\Windows\SysWOW64\ntdll.dll</Data> <Data>3c1e0a43-3d85-11e6-aad3-001e8cf18221</Data> </EventData> </Event>
这就是Apache错误日志所logging的错误时间(6/28/2016 8:08:33)。 可能会看到错误消息“服务器用完线程来处理请求,请考虑提高ThreadsPerChild设置”。 在这个消息之后,Apache再也没有工作了。 (以前的Apache错误日志消息logging得非常早,并且不相关。)
[Tue Jun 28 20:08:30 2016] [notice] Parent: Received shutdown signal -- Shutting down the server. [Tue Jun 28 20:08:31 2016] [notice] Child 3004: Exit event signaled. Child process is ending. [Tue Jun 28 20:08:32 2016] [info] Child 3004: Accept thread exiting. [Tue Jun 28 20:08:32 2016] [notice] Child 3004: Released the start mutex [Tue Jun 28 20:08:32 2016] [notice] Child 3004: Terminating 99 threads that failed to exit. [Tue Jun 28 20:08:32 2016] [notice] Child 3004: All worker threads have exited. [Tue Jun 28 20:08:32 2016] [info] [client 1.23.96.161] (OS 10038)An operation was attempted on something that is not a socket. : core_output_filter: writing data to the network [Tue Jun 28 20:08:34 2016] [notice] Parent: Child process exited successfully. [Tue Jun 28 20:08:34 2016] [info] removed PID file C:/Apache2.2/logs/httpd.pid (pid=284) [Tue Jun 28 20:08:54 2016] [notice] Apache/2.2.15 (Win32) configured -- resuming normal operations [Tue Jun 28 20:08:54 2016] [notice] Server built: Mar 4 2010 11:27:46 [Tue Jun 28 20:08:54 2016] [notice] Parent: Created child process 2468 [Tue Jun 28 20:08:54 2016] [info] Parent: Duplicating socket 308 and sending it to child process 2468 [Tue Jun 28 20:08:54 2016] [notice] Child 2468: Child process is running [Tue Jun 28 20:08:54 2016] [notice] Child 2468: Acquired the start mutex. [Tue Jun 28 20:08:54 2016] [notice] Child 2468: Starting 100 worker threads. [Tue Jun 28 20:08:54 2016] [notice] Child 2468: Starting thread to listen on port 80. [Tue Jun 28 20:08:56 2016] [warn] Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting
上面的错误之后,重新启动Windows和Apache服务没有解决问题(相同的错误消息)。 重新安装Apache并启动机器后,问题仍然存在(相同的错误信息)。 所以,我增加了“MaxRequestsPerChild”参数为300,但所有的工作线程在12秒内被消耗。 因此,我将“MaxRequestsPerChild”参数增加到了500,并重新启动了机器,但所有工作线程都在9秒钟内被消耗,如日志所示。
[Tue Jun 28 21:55:01 2016] [notice] Parent: Received shutdown signal -- Shutting down the server. [Tue Jun 28 21:55:01 2016] [notice] Child 864: Exit event signaled. Child process is ending. [Tue Jun 28 21:55:02 2016] [info] Child 864: Accept thread exiting. [Tue Jun 28 21:55:02 2016] [notice] Child 864: Released the start mutex [Tue Jun 28 21:55:20 2016] [error] [client 1.23.96.161] request failed: error reading the headers [Tue Jun 28 21:55:31 2016] [error] [client 1.23.96.161] request failed: error reading the headers [Tue Jun 28 21:55:31 2016] [error] [client 1.23.96.161] request failed: error reading the headers [Tue Jun 28 21:55:31 2016] [notice] Parent: Forcing termination of child process 368 [Tue Jun 28 21:55:31 2016] [info] removed PID file C:/Apache2.2/logs/httpd.pid (pid=2252) [Tue Jun 28 22:10:13 2016] [notice] Apache/2.2.15 (Win32) configured -- resuming normal operations [Tue Jun 28 22:10:13 2016] [notice] Server built: Mar 4 2010 11:27:46 [Tue Jun 28 22:10:13 2016] [notice] Parent: Created child process 1452 [Tue Jun 28 22:10:13 2016] [notice] Child 1452: Child process is running [Tue Jun 28 22:10:13 2016] [info] Parent: Duplicating socket 308 and sending it to child process 1452 [Tue Jun 28 22:10:13 2016] [notice] Child 1452: Acquired the start mutex. [Tue Jun 28 22:10:13 2016] [notice] Child 1452: Starting 500 worker threads. [Tue Jun 28 22:10:13 2016] [notice] Child 1452: Starting thread to listen on port 80. [Tue Jun 28 22:10:22 2016] [warn] Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting
下面你可以看到我的完整的原始httpd.conf。 几个月来它一直在正常工作。 (我删除了所有的注释行,使它更小,更具可读性,并用“xxxxx”屏蔽了一些最小的敏感数据):
ServerRoot "C:/Apache2.2" Listen 80 LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule authn_default_module modules/mod_authn_default.so LoadModule authn_file_module modules/mod_authn_file.so LoadModule authz_default_module modules/mod_authz_default.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule cgi_module modules/mod_cgi.so LoadModule deflate_module modules/mod_deflate.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so LoadModule expires_module modules/mod_expires.so LoadModule headers_module modules/mod_headers.so LoadModule include_module modules/mod_include.so LoadModule isapi_module modules/mod_isapi.so LoadModule log_config_module modules/mod_log_config.so LoadModule mime_module modules/mod_mime.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule setenvif_module modules/mod_setenvif.so <IfModule !mpm_netware_module> <IfModule !mpm_winnt_module> User daemon Group daemon </IfModule> </IfModule> ServerAdmin xxxxxxxxxxxxxxxxxxxxxxxx ServerName xxxxxxxxxxxxxxxxxxxxxxxx:80 DocumentRoot "xxxxxxxxxxxxxxxxxxxxxxxx" <Directory /> Options FollowSymLinks AllowOverride None Order deny,allow Deny from all </Directory> <Directory "xxxxxxxxxxxxxxxxxxxxxxxx"> Options FollowSymLinks Options +Includes Options -Indexes AllowOverride None Order allow,deny Allow from all LimitRequestBody 10485760 SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <FilesMatch "^\.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch> <IfModule mod_headers.c> Header always append X-Frame-Options SAMEORIGIN </IfModule> <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 week" ExpiresByType text/css "access plus 1 week" ExpiresByType application/atom+xml "access plus 1 hour" ExpiresByType application/rdf+xml "access plus 1 hour" ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/json "access plus 0 seconds" ExpiresByType application/ld+json "access plus 0 seconds" ExpiresByType application/schema+json "access plus 0 seconds" ExpiresByType application/vnd.geo+json "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType text/xml "access plus 0 seconds" ExpiresByType image/vnd.microsoft.icon "access plus 1 week" ExpiresByType image/x-icon "access plus 1 week" ExpiresByType text/html "access plus 1 day" ExpiresByType application/javascript "access plus 1 week" ExpiresByType application/x-javascript "access plus 1 week" ExpiresByType text/javascript "access plus 1 week" ExpiresByType application/manifest+json "access plus 1 year" ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" ExpiresByType text/cache-manifest "access plus 0 seconds" ExpiresByType audio/ogg "access plus 1 month" ExpiresByType image/bmp "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/ogg "access plus 1 month" ExpiresByType video/webm "access plus 1 month" <Directory xxxxxxxxxxxxxxxxxxxxxxxx> ExpiresByType image/gif "access plus 0 seconds" ExpiresByType image/jpeg "access plus 0 seconds" ExpiresByType image/png "access plus 0 seconds" </Directory> ExpiresByType application/vnd.ms-fontobject "access plus 1 month" ExpiresByType font/eot "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType application/font-woff "access plus 1 month" ExpiresByType application/x-font-woff "access plus 1 month" ExpiresByType font/woff "access plus 1 month" ExpiresByType application/font-woff2 "access plus 1 month" ExpiresByType text/x-cross-domain-policy "access plus 1 week" </IfModule> ErrorLog "|bin/rotatelogs logs/error.%Y-%m-%d.log 50M" LogLevel info <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "|bin/rotatelogs logs/access.%Y-%m-%d---%H.log 300M" common </IfModule> <IfModule alias_module> ScriptAlias /p2p/ "xxxxxxxxxxxxxxxxxxxxxxxx" </IfModule> <IfModule cgid_module> </IfModule> <Directory "xxxxxxxxxxxxxxxxxxxxxxxx"> AllowOverride None Options None Order allow,deny Allow from all </Directory> DefaultType text/plain <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType text/html .html AddHandler server-parsed .html </IfModule> <IfModule mpm_winnt_module> ThreadsPerChild 100 MaxMemFree 100 MaxRequestsPerChild 5000 </IfModule> <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> RewriteEngine On RewriteCond %{HTTP_HOST} !^www RewriteRule (.*) http://www.%{HTTP_HOST}$1 [L,R]
如上所示,我的Apache在启动后几乎立即停止响应。
我的网站不连接到数据库。 它只是通过使用CGI服务dynamic页面。
有没有办法清理系统,使Apache再次工作,因为它曾经在这个神秘的崩溃之前工作?
任何人都可以给我任何build议来解决这个问题,或者至less得到一个解决方法?
提前致谢。