{"id":36259,"date":"2022-11-05T02:31:15","date_gmt":"2022-11-07T04:12:35","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/"},"modified":"2024-04-28T23:04:59","modified_gmt":"2024-04-28T15:04:59","slug":"apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/","title":{"rendered":"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09"},"content":{"rendered":"<h1>\u9996\u5148<\/h1>\n<p>\u5f53\u4f7f\u7528Apache\u516c\u5f00Web\u670d\u52a1\u5668\u65f6\uff0c\u6839\u636e\u516c\u5f00\u8303\u56f4\u548c\u89c4\u6a21\u7684\u4e0d\u540c\uff0c\u9700\u8981\u5bf9Apache\u8fdb\u884c\u914d\u7f6e\u8c03\u4f18\u3002\u8fd9\u91cc\u6211\u4eec\u5c06\u4ecb\u7ecdprefork\u8c03\u4f18\u7684\u4e00\u79cd\u4f8b\u5b50\u3002<\/p>\n<h1>prefork\u662f\u4ec0\u4e48\uff1f<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Apache\u306e\u30d7\u30ed\u30bb\u30b9\u306e\u6319\u52d5\u306e\u65b9\u5f0f\u306e\u4e00\u3064<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30b9\u30ec\u30c3\u30c9\u3092\u4f7f\u308f\u305a\u306b\u3001fork\uff08\u81ea\u5206\u81ea\u8eab\u306e\u30b3\u30d4\u30fc\uff09\u3092\u884c\u3046\uff1dprefork<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u3042\u3089\u304b\u3058\u3081\uff08pre\uff09Apache\u306e\u5b50\u30d7\u30ed\u30bb\u30b9\u3092\u30b3\u30d4\u30fc\uff08fork\uff09\u3057\u3066\u304a\u304d\u3001fork\u306e\u5f85\u3061\u6642\u9593\u3092\u6e1b\u3089\u3059\u3053\u3068\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u4e0a\u3052\u3066\u3044\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">fork\u3055\u308c\u305f\u5b50\u30d7\u30ed\u30bb\u30b9\u4e00\u3064\u4e00\u3064\u304c\u901a\u4fe1\u3092\u53d7\u3051\u6301\u3064<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u4ed6\u306e\u5b50\u30d7\u30ed\u30bb\u30b9\u304c\u304a\u304b\u3057\u306a\u6319\u52d5\u3092\u3057\u3066\u3082\u3001\u4ed6\u306e\u5b50\u30d7\u30ed\u30bb\u30b9\u306b\u306f\u5f71\u97ff\u304c\u306a\u3044\u305f\u3081\u3001\u5b89\u5b9a\u3057\u305f\u901a\u4fe1\u304c\u53ef\u80fd<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">prefork\u3067\u591a\u6570\u306e\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u88c1\u304f\u306b\u306f\u3001\u591a\u6570\u306e\u30e1\u30e2\u30ea\u30fbCPU\u3092\u4f7f\u7528\u3059\u308b<\/ul>\n<h1>\u524d\u63d0\u662f\u4e00\u4e2a\u5047\u8bbe\u6761\u4ef6\u6216\u662f\u5c40\u9650\uff0c\u5b83\u6307\u7684\u662f\u4e00\u4e2a\u5fc5\u987b\u6210\u7acb\u6216\u88ab\u63a5\u53d7\u7684\u57fa\u7840\u8981\u7d20\u3002<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">CentOS7.2<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Apache2.4<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30b5\u30a4\u30b8\u30f3\u30b0\u6e08\u307f\uff08\u60f3\u5b9a\u3055\u308c\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u6570\u3001\u4f7f\u7528\u30e1\u30e2\u30ea\u3001CPU\u306f\u8a08\u7b97\u6e08\u307f\uff09<\/ul>\n<h1>\u8bbe\u7f6e\u65b9\u5f0f<\/h1>\n<p>\u4e3a\u4e86\u4f7f\u8bbe\u7f6e\u66f4\u52a0\u6e05\u6670\u6613\u61c2\uff0c\u8fd9\u6b21\u5c06\u8bb0\u5f55\u5728\u4e00\u4e2a\u540d\u4e3ampm.conf\u7684\u6587\u4ef6\u4e2d\u3002<br \/>\n\u2192\u4e5f\u53ef\u4ee5\u8bb0\u5f55\u5728httpd.conf\u4e2d\u3002<\/p>\n<p>\u786e\u8ba4\u8fdb\u7a0b\u7684\u884c\u4e3a\u6a21\u5f0f<\/p>\n<blockquote><p>\u6709\u4e00\u4e2a\u540d\u4e3aworker\u7684\u4e0eprefork\u7c7b\u4f3c\u7684\u9009\u9879\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662fprefork\uff0c\u4f46\u4e3a\u4e86\u4fdd\u9669\u8d77\u89c1\uff0c\u8bf7\u518d\u786e\u8ba4\u4e00\u4e0b\u3002<\/p><\/blockquote>\n<pre class=\"post-pre\"><code># apachectl -V\r\nServer version: Apache\/2.4.25 (CentOS)\r\nServer built:   Jan  6 2017 14:54:10\r\nServer's Module Magic Number: 20120211:67\r\nServer loaded:  APR 1.5.2, APR-UTIL 1.5.4\r\nCompiled using: APR 1.5.2, APR-UTIL 1.5.4\r\nArchitecture:   64-bit\r\nServer MPM:     prefork \u2190\u2605\u3053\u3053\u3092\u78ba\u8a8d\uff01\r\n  threaded:     no\r\n    forked:     yes (variable process count)\r\nServer compiled with....\r\n -D APR_HAS_SENDFILE\r\n -D APR_HAS_MMAP\r\n -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)\r\n -D APR_USE_SYSVSEM_SERIALIZE\r\n -D APR_USE_PTHREAD_SERIALIZE\r\n -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\r\n -D APR_HAS_OTHER_CHILD\r\n -D AP_HAVE_RELIABLE_PIPED_LOGS\r\n -D DYNAMIC_MODULE_LIMIT=256\r\n -D HTTPD_ROOT=\"\/etc\/httpd\"\r\n -D SUEXEC_BIN=\"\/usr\/sbin\/suexec\"\r\n -D DEFAULT_PIDLOG=\"\/run\/httpd\/httpd.pid\"\r\n -D DEFAULT_SCOREBOARD=\"logs\/apache_runtime_status\"\r\n -D DEFAULT_ERRORLOG=\"logs\/error_log\"\r\n -D AP_TYPES_CONFIG_FILE=\"conf\/mime.types\"\r\n -D SERVER_CONFIG_FILE=\"conf\/httpd.conf\"\r\n<\/code><\/pre>\n<p>\u670d\u52a1\u5668MPM\uff1a\u53ea\u8981\u662fprefork\u5c31\u53ef\u4ee5\uff01<\/p>\n<p>2. \u8fdb\u884c\u8bbe\u5b9a\u4e4b\u524d\u7684\u786e\u8ba4<\/p>\n<blockquote><p>\u8fd9\u6b21\u6211\u4eec\u8981\u589e\u52a0 Apache \u7684\u8fdb\u7a0b\u6570\uff0c\u6240\u4ee5\u8ba9\u6211\u4eec\u5148\u786e\u8ba4\u4e00\u4e0b\u589e\u52a0\u4e4b\u524d\u7684\u72b6\u6001\u3002<\/p><\/blockquote>\n<pre class=\"post-pre\"><code># ps -ef | grep httpd\r\nroot       941     1  0 Mar21 ?        00:00:16 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    2149   941  0 Mar21 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    2150   941  0 Mar21 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    2151   941  0 Mar21 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    2152   941  0 Mar21 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    2153   941  0 Mar21 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\nroot      8109  8035  0 14:35 pts\/0    00:00:00 grep httpd\r\n<\/code><\/pre>\n<p>\u8bb0\u4f4f\u8fd9\u4e2a\u6570\u5b57\uff01<br \/>\n\u5728\u8fdb\u884c\u57fa\u672c\u8bbe\u7f6e\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u8fdb\u884c\u4e86\u4e8b\u524d\u786e\u8ba4\uff01<br \/>\n\u5982\u679c\u4e0d\u8fd9\u6837\u505a\uff0c\u5c31\u65e0\u6cd5\u77e5\u9053\u8bbe\u7f6e\u540e\u7684\u53d8\u5316\u662f\u4ec0\u4e48\u4e86&#8230;<\/p>\n<p>\u521b\u5efampm.conf\u6587\u4ef6<\/p>\n<blockquote><p>\u8bf7\u521b\u5efa\u4e00\u4e2a\u8bb0\u5f55Apache\u8c03\u4f18\u5185\u5bb9\u7684\u6587\u4ef6\u3002<br \/>\n\u53ef\u4ee5\u4f7f\u7528vi\u547d\u4ee4\u4e00\u6b21\u6027\u521b\u5efa\u5e76\u8fdb\u884c\u5199\u5165\u3002<\/p><\/blockquote>\n<pre class=\"post-pre\"><code># touch \/etc\/httpd\/conf.d\/mpm.conf\r\n<\/code><\/pre>\n<p>4. \u5728 mpm.conf \u6587\u4ef6\u4e2d\u5199\u5165<\/p>\n<blockquote><p>\u4ee5\u4e0b\u662f\u5b9e\u9645\u7684\u8c03\u6574\u5185\u5bb9\u3002<br \/>\n\u203b \u8c03\u6574\u5185\u5bb9\u4f1a\u56e0\u5927\u5c0f\u5c3a\u5bf8\u4e0d\u540c\u800c\u6709\u6240\u4e0d\u540c\uff01<\/p><\/blockquote>\n<pre class=\"post-pre\"><code>&lt;IfModule mpm_prefork_module&gt;\r\n    StartServers 400\u3000\u2190\u8d77\u52d5\u6642\u306b\u751f\u6210\u3055\u308c\u308b\u5b50\u30b5\u30fc\u30d0\u30d7\u30ed\u30bb\u30b9\u306e\u6570\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f5\u3002\r\n    MinSpareServers 400\u3000\u2190\u30a2\u30a4\u30c9\u30eb\u72b6\u614b\u306b\u3044\u308b\u5b50\u30b5\u30fc\u30d0\u30d7\u30ed\u30bb\u30b9\u306e\u6700\u5c0f\uff08\u5e0c\u671b\uff09\u500b\u6570\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f5\u3002\r\n    MaxSpareServers 400\u3000\u2190\u30a2\u30a4\u30c9\u30eb\u72b6\u614b\u306b\u3044\u308b\u5b50\u30b5\u30fc\u30d0\u30d7\u30ed\u30bb\u30b9\u306e\u6700\u5927\uff08\u5e0c\u671b\uff09\u500b\u6570\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f10\u3002\r\n    ServerLimit 400\u3000\u2190MaxClients\u306b\u6307\u5b9a\u53ef\u80fd\u306a\u5024\u306e\u4e0a\u9650\u3002\uff08MaxClient\u3088\u308a\u5927\u304d\u306a\u6570\u306b\u3059\u308b\uff09\r\n    MaxClients 400\u3000\u2190\u5fdc\u7b54\u3067\u304d\u308b\u540c\u6642\u30ea\u30af\u30a8\u30b9\u30c8\u6570\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f256\u3002\r\n    MaxRequestsPerChild 80\u3000\u2190\u500b\u3005\u306e\u5b50\u30b5\u30fc\u30d0\u30d7\u30ed\u30bb\u30b9\u304c\u6271\u3046\u3053\u3068\u306e\u3067\u304d\u308b\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u7dcf\u6570\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306f10000\u30020\u306b\u3059\u308b\u3068\u7121\u5236\u9650\r\n&lt;\/IfModule&gt;\r\n<\/code><\/pre>\n<p>\u5728httpd.conf\u6587\u4ef6\u4e2d\u8fdb\u884c\u6dfb\u52a0<\/p>\n<blockquote><p>\u8fd9\u6b21\u6211\u8fd8\u989d\u5916\u8ffd\u52a0\u4e86\u4e0b\u9762\u7684\u5185\u5bb9\u3002<\/p><\/blockquote>\n<pre class=\"post-pre\"><code>KeepAlive On\u3000\u2190\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u306e\u63a5\u7d9a\u8981\u6c42\u6642\u306b\u5373\u5ea7\u306b\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u9589\u3058\u306a\u3044\u3088\u3046\u306b\u3059\u308b\u8a2d\u5b9a\r\nMaxKeepAliveRequests 80\u3000\u2190\u4e00\u5ea6\u306b\u51e6\u7406\u3067\u304d\u308b\u6570\u306e\u6700\u5927\u5024\uff081\u30da\u30fc\u30b8\u3042\u305f\u308a\u306e\u5e73\u5747\u30d5\u30a1\u30a4\u30eb\u6570+\u03b1\u304c\u53c2\u8003\u5024\uff09\r\nKeepAliveTimeout 120\u3000\u2190KeepAlive\u6709\u52b9\u6642\u306b\u63a5\u7d9a\u8981\u6c42\u3092\u53d7\u3051\u4ed8\u3051\u308b\u6570\u306e\u6700\u5927\u8a31\u5bb9\u5024\uff081\u30da\u30fc\u30b8\u5f53\u305f\u308a\u306e\u5e73\u5747\u7684\u306a\u8ee2\u9001\u6642\u9593+\u03b1\u304c\u53c2\u8003\u5024\uff09\r\n<\/code><\/pre>\n<p>6. \u8bbe\u5b9a\u7684\u5e94\u7528<\/p>\n<blockquote><p>\u4e3a\u4e86\u5e94\u7528\u4e0a\u8ff0\u8bbe\u7f6e\uff0c\u6211\u4eec\u5c06\u91cd\u65b0\u542f\u52a8Apache\u3002<\/p><\/blockquote>\n<pre class=\"post-pre\"><code># systemctl restart httpd\r\n<\/code><\/pre>\n<p>7. \u78ba\u8a8d\u8a2d\u5b9a\u540e\u7684\u8fdb\u7a0b\u3002<\/p>\n<blockquote><p>\u8ba9\u6211\u4eec\u5c06\u6b65\u9aa42\u8fdb\u884c\u6bd4\u8f83\u5427\uff01<\/p><\/blockquote>\n<pre class=\"post-pre\"><code># ps -ef | grep httpd\r\nroot      8120     1 87 14:36 ?        00:00:05 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8121  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8123  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8124  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8126  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8129  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8131  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8133  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8134  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8136  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8137  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8139  8120  1 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8140  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8141  8120  1 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8142  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8143  8120  2 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8144  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8145  8120  2 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8146  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8147  8120  1 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8148  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8149  8120  1 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8163  8120  1 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8165  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8167  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8169  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8171  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8173  8120  0 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8175  8120  1 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8177  8120  5 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8179  8120  2 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8181  8120  4 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8183  8120  2 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\napache    8185  8120  8 14:36 ?        00:00:00 \/usr\/sbin\/httpd -DFOREGROUND\r\nroot      8188  8035  0 14:36 pts\/0    00:00:00 grep httpd\r\n<\/code><\/pre>\n<p>\u589e\u957f\u5f88\u5927\uff01\u7531\u4e8e\u5185\u5b58\u548cCPU\u5bb9\u91cf\u4f30\u8ba1\u5931\u8bef\u4f1a\u5bfc\u81f4\u670d\u52a1\u5668\u5b95\u673a\uff0c\u6240\u4ee5\u6211\u4eec\u8981\u51c6\u786e\u8ba1\u7b97\u5bb9\u91cf\u3002<br \/>\n\u6211\u8bb0\u5f97\u5f53\u65f6\u5b89\u88c5\u7684\u662f5\u53f032GB\u5185\u5b58\u7684\u670d\u52a1\u5668\u2026\u2026\uff08\u6211\u8bb0\u5f97\u4e0d\u592a\u6e05\u695a\u2026\u2026\uff09<\/p>\n<p>\u7cdf\u7cd5\uff01 or \u4e0d\u597d\u4e86\uff01<\/p>\n<h1>\u95f2\u8c08<\/h1>\n<h3>\u4e3a\u4ec0\u4e48\u9009\u62e9\u5c06\u5176\u547d\u540d\u4e3ampm.conf\uff1f<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">mpm_prefork_module\u3092\u4f7f\u3063\u3066\u3044\u308b\u304b\u3089<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">MPM\uff1d\u30de\u30eb\u30c1\u30d7\u30ed\u30bb\u30c3\u30b7\u30f3\u30b0\u30e2\u30b8\u30e5\u30fc\u30eb<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30de\u30eb\u30c1\u30d7\u30ed\u30bb\u30b9\u3068\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3054\u3068\u306bfork\u3092\u884c\u3044\u3001\u5b50\u30d7\u30ed\u30bb\u30b9\u3092\u751f\u6210\u3057\u3001\u51e6\u7406\u3092\u3057\u3066\u3082\u3089\u3046<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">MPM\u3068\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3059\u308b\u90e8\u5206\u306e\u3053\u3068\u3092\u6307\u3059<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">prefork, worker, event\u306a\u3069\u304c\u3042\u308b<\/ul>\n<h3>\u5de5\u4eba\u662f\u6307\u4e00\u4f4d\u4ece\u4e8b\u52b3\u52a8\u5de5\u4f5c\u7684\u4eba\u3002<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u5b50\u30d7\u30ed\u30bb\u30b9\u304c\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u3067\u64cd\u4f5c\u3057\u3001\u30b9\u30ec\u30c3\u30c9\u304c\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3092\u53d7\u3051\u6301\u3064<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">1\u3064\u306e\u30d7\u30ed\u30bb\u30b9\u304c\u8907\u6570\u306e\u901a\u4fe1\u3092\u884c\u3046\uff08\u30d7\u30ed\u30bb\u30b9\u306e\u4e2d\u306b\u3001\u901a\u4fe1\u3092\u3059\u308b\u30b9\u30ec\u30c3\u30c9\u304c\u8907\u6570\u3044\u308b\uff09<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u30d7\u30ed\u30bb\u30b9\u306e\u8d77\u52d5\u3092\u6291\u3048\u308b\u3053\u3068\u304c\u53ef\u80fd\u306a\u305f\u3081\u3001CPU\u3084\u30e1\u30e2\u30ea\u306e\u4f7f\u7528\u7387\u3092\u6291\u3048\u308b\u3053\u3068\u304c\u53ef\u80fd<\/ul>\n<h3>event\u662f\u6307\u4e00\u500b\u7279\u5b9a\u7684\u6d3b\u52d5\u6216\u5834\u5408\u3002<\/h3>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">worker\u3068\u540c\u3058\u3067\u3001\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u3067\u52d5\u4f5c\u3059\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u9055\u3044\u306f\u3001Keep-Alive\uff08\u6301\u7d9a\u7684\u63a5\u7d9a\uff09\u306e\u51e6\u7406\u65b9\u6cd5<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">prefork\u3084worker\u306f\u540c\u3058\u30d7\u30ed\u30bb\u30b9\u3084\u30b9\u30ec\u30c3\u30c9\u3092\u6301\u7d9a\u63a5\u7d9a\u306e\u969b\u306b\u5229\u7528\u3059\u308b\u304c\u3001worker\u3067\u306f\u5225\u306e\u30b9\u30ec\u30c3\u30c9\u306b\u5272\u308a\u632f\u308b<\/ul>\n<h2>MPM\u7684\u5207\u6362\u65b9\u6cd5\uff08Apache2.4\uff09<\/h2>\n<p>\u5c06\u9ed8\u8ba4\u7684prefork\u6a21\u5f0f\u66f4\u6539\u4e3aworker\u6a21\u5f0f\u3002<\/p>\n<p>1. \u8bf7\u4e8b\u5148\u786e\u8ba4\u53d8\u66f4\u524d\u7684\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code># apachectl -V | grep MPM\r\nServer MPM:     prefork\r\n<\/code><\/pre>\n<p>2. \u5207\u6362\u5230MPM<\/p>\n<pre class=\"post-pre\"><code># \/etc\/httpd\/conf.modules.d\/00-mpm.conf\r\n# Select the MPM module which should be used by uncommenting exactly\r\n# one of the following LoadModule lines:\r\n\r\n# prefork MPM: Implements a non-threaded, pre-forking web server\r\n# See: http:\/\/httpd.apache.org\/docs\/2.4\/mod\/prefork.html\r\n#LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so\u3000\u2190\u2605\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u307e\u3059\uff01\r\n\r\n# worker MPM: Multi-Processing Module implementing a hybrid\r\n# multi-threaded multi-process web server\r\n# See: http:\/\/httpd.apache.org\/docs\/2.4\/mod\/worker.html\r\n#\r\nLoadModule mpm_worker_module modules\/mod_mpm_worker.so\u3000\u2190\u2605\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3092\u5916\u3057\u307e\u3059\uff01\r\n\r\n# event MPM: A variant of the worker MPM with the goal of consuming\r\n# threads only for connections with active processing\r\n# See: http:\/\/httpd.apache.org\/docs\/2.4\/mod\/event.html\r\n#\r\n#LoadModule mpm_event_module modules\/mod_mpm_event.so\r\n<\/code><\/pre>\n<p>3. \u5e94\u7528\u8bbe\u7f6e\u7684\u66f4\u65b0<\/p>\n<pre class=\"post-pre\"><code># systemctl restart httpd\r\n<\/code><\/pre>\n<p>4. \u78ba\u8a8d\u8a2d\u5b9a\u5df2\u5b8c\u6210\u3002<\/p>\n<pre class=\"post-pre\"><code># apachectl -V | grep MPM\r\nServer MPM:     worker\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u5f53\u4f7f\u7528Apache\u516c\u5f00Web\u670d\u52a1\u5668\u65f6\uff0c\u6839\u636e\u516c\u5f00\u8303\u56f4\u548c\u89c4\u6a21\u7684\u4e0d\u540c\uff0c\u9700\u8981\u5bf9Apache\u8fdb\u884c\u914d\u7f6e\u8c03\u4f18\u3002\u8fd9\u91cc\u6211\u4eec [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-36259","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/apache\u8c03\u4f18\u65b9\u6cd5\uff08apache2-4\uff0cprefork\uff09\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u5f53\u4f7f\u7528Apache\u516c\u5f00Web\u670d\u52a1\u5668\u65f6\uff0c\u6839\u636e\u516c\u5f00\u8303\u56f4\u548c\u89c4\u6a21\u7684\u4e0d\u540c\uff0c\u9700\u8981\u5bf9Apache\u8fdb\u884c\u914d\u7f6e\u8c03\u4f18\u3002\u8fd9\u91cc\u6211\u4eec [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/apache\u8c03\u4f18\u65b9\u6cd5\uff08apache2-4\uff0cprefork\uff09\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-07T04:12:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T15:04:59+00:00\" \/>\n<meta name=\"author\" content=\"\u9038, \u79d1\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u9038, \u79d1\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/\",\"name\":\"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-11-07T04:12:35+00:00\",\"dateModified\":\"2024-04-28T15:04:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487\",\"name\":\"\u9038, \u79d1\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g\",\"caption\":\"\u9038, \u79d1\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keyi\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/apache\u8c03\u4f18\u65b9\u6cd5\uff08apache2-4\uff0cprefork\uff09\/","og_locale":"zh_CN","og_type":"article","og_title":"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09","og_description":"\u9996\u5148 \u5f53\u4f7f\u7528Apache\u516c\u5f00Web\u670d\u52a1\u5668\u65f6\uff0c\u6839\u636e\u516c\u5f00\u8303\u56f4\u548c\u89c4\u6a21\u7684\u4e0d\u540c\uff0c\u9700\u8981\u5bf9Apache\u8fdb\u884c\u914d\u7f6e\u8c03\u4f18\u3002\u8fd9\u91cc\u6211\u4eec [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/apache\u8c03\u4f18\u65b9\u6cd5\uff08apache2-4\uff0cprefork\uff09\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-11-07T04:12:35+00:00","article_modified_time":"2024-04-28T15:04:59+00:00","author":"\u9038, \u79d1","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u9038, \u79d1","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/","name":"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-11-07T04:12:35+00:00","dateModified":"2024-04-28T15:04:59+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Apache\u8c03\u4f18\u65b9\u6cd5\uff08Apache2.4\uff0cprefork\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/85c1dae56e6ea1e695c73d33c684d487","name":"\u9038, \u79d1","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c94f6d9cbbfbca863fab309840bd690c153c95f8490c290ad2ed54dd693dad16?s=96&d=mm&r=g","caption":"\u9038, \u79d1"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keyi\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/apache%e8%b0%83%e4%bc%98%e6%96%b9%e6%b3%95%ef%bc%88apache2-4%ef%bc%8cprefork%ef%bc%89\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=36259"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36259\/revisions"}],"predecessor-version":[{"id":63728,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/36259\/revisions\/63728"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=36259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=36259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=36259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}