{"id":34078,"date":"2026-10-27T10:00:00","date_gmt":"2026-10-27T02:00:00","guid":{"rendered":"https:\/\/cn.hostease.com\/blog\/?p=34078"},"modified":"2026-10-23T12:06:59","modified_gmt":"2026-10-23T04:06:59","slug":"apache-to-nginx-migration-playbook","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/blog\/tutorials\/apache-to-nginx-migration-playbook\/","title":{"rendered":"\u4ece Apache \u8fc1\u79fb\u5230 Nginx\uff1a\u6027\u80fd\u63d0\u5347\u4e0e\u914d\u7f6e\u8fc1\u79fb\u6307\u5357"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/08\/apache-to-nginx-migration-cover.webp\" alt=\"\u4ece Apache \u8fc1\u79fb\u5230 Nginx\uff1a\u6027\u80fd\u63d0\u5347\u4e0e\u914d\u7f6e\u8fc1\u79fb\u6307\u5357 \u5c01\u9762\u914d\u56fe\" loading=\"lazy\" \/><\/p>\n<p>\u5f53\u7f51\u7ad9\u7684\u5e76\u53d1\u8bbf\u95ee\u91cf\u4e0a\u6765\u4e4b\u540e\uff0c\u5f88\u591a\u7ad9\u957f\u4f1a\u53d1\u73b0 Apache \u7684\u5185\u5b58\u5360\u7528\u6301\u7eed\u6500\u5347\uff0c\u9875\u9762\u54cd\u5e94\u8d8a\u6765\u8d8a\u6162\uff0c\u8fd9\u65f6\u5019\u6700\u5e38\u89c1\u7684\u7591\u95ee\u5c31\u662f\uff1a\u5982\u4f55\u628a\u7f51\u7ad9\u4ece Apache \u5e73\u6ed1\u8fc1\u79fb\u5230 Nginx\uff0c\u540c\u65f6\u4e0d\u4e22\u914d\u7f6e\u3001\u4e0d\u65ad\u8bbf\u95ee\uff1f\u8fd9\u7bc7\u6587\u7ae0\u4f1a\u5e2e\u4f60\u89e3\u51b3\u8fd9\u4e2a\u8fc1\u79fb\u8fc7\u7a0b\u4e2d\u6700\u68d8\u624b\u7684\u51e0\u4e2a\u95ee\u9898\uff1aApache \u7684<a href=\"https:\/\/cn.hostease.com\/web-hosting\/\">\u865a\u62df\u4e3b\u673a<\/a>\u548c\u91cd\u5199\u89c4\u5219\u5982\u4f55\u7ffb\u8bd1\u6210 Nginx \u8bed\u6cd5\u3001PHP \u5904\u7406\u65b9\u5f0f\u7684\u5dee\u5f02\u600e\u4e48\u8854\u63a5\u3001\u8fc1\u79fb\u524d\u540e\u7684\u6027\u80fd\u600e\u4e48\u5bf9\u6bd4\u9a8c\u8bc1\uff0c\u4ee5\u53ca\u51fa\u95ee\u9898\u65f6\u5982\u4f55\u5feb\u901f\u56de\u6eda\u3002<\/p>\n<p>\u5148\u7ed9\u51fa\u6838\u5fc3\u7ed3\u8bba\uff1aApache \u4e3a\u6bcf\u4e2a\u8fde\u63a5\u5206\u914d\u4e00\u4e2a\u8fdb\u7a0b\/\u7ebf\u7a0b\uff0c\u9759\u6001\u8d44\u6e90\u591a\u3001\u5e76\u53d1\u9ad8\u7684\u7ad9\u70b9\u5207\u5230 Nginx \u540e\uff0c\u5185\u5b58\u5360\u7528\u548c\u54cd\u5e94\u65f6\u95f4\u901a\u5e38\u660e\u663e\u6539\u5584\uff1b\u4f46 Nginx \u4e0d\u652f\u6301 <code>.htaccess<\/code>\uff0c\u91cd\u5199\u89c4\u5219\u5fc5\u987b\u96c6\u4e2d\u5230\u4e3b\u914d\u7f6e\u91cc\uff0c\u8fd9\u662f\u8fc1\u79fb\u6700\u5bb9\u6613\u8e29\u5751\u7684\u5730\u65b9\u3002<\/p>\n<h2>\u8fc1\u79fb\u524d\uff1a\u4e3a\u4ec0\u4e48 Nginx \u5728\u9ad8\u5e76\u53d1\u4e0b\u66f4\u7701\u8d44\u6e90<\/h2>\n<p>\u4e24\u79cd\u670d\u52a1\u5668\u7684\u6839\u672c\u533a\u522b\u5728\u8fde\u63a5\u5904\u7406\u6a21\u578b\uff1aApache \u7684 prefork \u6a21\u5f0f\u4e3a\u6bcf\u4e2a\u8fde\u63a5\u5206\u914d\u72ec\u7acb\u8fdb\u7a0b\uff0cworker\/event \u6a21\u5f0f\u867d\u6539\u7528\u7ebf\u7a0b\u548c\u4e8b\u4ef6\u673a\u5236\uff0c\u4f46\u6bcf\u4e2a\u8fde\u63a5\u4ecd\u8981\u5360\u7528\u4e00\u4e2a\u7ebf\u7a0b\u6808\uff1bNginx \u5219\u662f\u4e8b\u4ef6\u9a71\u52a8\u52a0\u5f02\u6b65\u975e\u963b\u585e\uff0c\u4e00\u4e2a worker \u8fdb\u7a0b\u53ef\u540c\u65f6\u6258\u7ba1\u6570\u5343\u4e2a\u8fde\u63a5\uff0c\u7a7a\u95f2\u8fde\u63a5\u51e0\u4e4e\u4e0d\u5360\u5185\u5b58\u3002<\/p>\n<p>\u4e3e\u4e00\u4e2a\u5177\u4f53\u573a\u666f\uff1a\u4e00\u53f0 2 \u6838 4GB \u7684 <a href=\"https:\/\/cn.hostease.com\/vps\/\">VPS<\/a>\uff08<a href=\"https:\/\/cn.hostease.com\/vps\/\">\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668<\/a>\uff09\uff0c\u9996\u9875\u6709 40 \u591a\u4e2a\u9759\u6001\u8d44\u6e90\u8bf7\u6c42\u3002\u67d0\u7535\u5546\u7ad9\u5728 Apache prefork \u6a21\u5f0f\u4e0b\u538b\u6d4b\uff0c300 \u5e76\u53d1\u65f6\u6bcf\u4e2a\u8fdb\u7a0b\u5360 8-15MB \u5185\u5b58\uff0c\u8fdb\u7a0b\u6570\u5f88\u5feb\u903c\u8fd1 <code>MaxRequestWorkers<\/code> \u4e0a\u9650\uff0c\u6392\u961f\u8bf7\u6c42\u7684\u54cd\u5e94\u65f6\u95f4\u4ece 80ms \u6da8\u5230 2 \u79d2\u4ee5\u4e0a\uff1b\u540c\u6837\u6d41\u91cf\u5207\u5230 Nginx \u540e\uff0c4 \u4e2a worker \u603b\u5185\u5b58\u7a33\u5b9a\u5728 50MB \u5de6\u53f3\uff0c\u9759\u6001\u9875\u9762 95 \u5206\u4f4d\u54cd\u5e94\u4fdd\u6301\u5728 100ms \u4ee5\u5185\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/10\/apache-to-nginx-performance.webp\" alt=\"Apache \u4e0e Nginx \u8d44\u6e90\u5360\u7528\u5bf9\u6bd4\u793a\u610f\u56fe\" loading=\"lazy\" \/><\/p>\n<p>\u5982\u679c\u4f60\u5728<a href=\"https:\/\/cn.hostease.com\/web-hosting\/\">\u5171\u4eab\u4e3b\u673a<\/a>\u4e0a\u6ca1\u6709\u6743\u9650\u5207\u6362\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u5148\u4ece\u5e94\u7528\u5c42\u5165\u624b\u51cf\u5c11\u8d44\u6e90\u6d88\u8017\uff0c\u6bd4\u5982\u53c2\u8003\u8fd9\u7bc7 TTFB\uff08\u9996\u5b57\u8282\u65f6\u95f4\uff09\u4f18\u5316\u6307\u5357\uff1a<a href=\"https:\/\/cn.hostease.com\/blog\/guides\/ttfb-hosting-optimization\/\">\u7f51\u7ad9\u6027\u80fd\u4f18\u5316\uff1aTTFB \u4f18\u5316\u65b9\u6cd5<\/a>\u3002\u800c\u5f53\u4f60\u62e5\u6709 VPS\uff08\u865a\u62df<a href=\"https:\/\/cn.hostease.com\/dedicated-server\/\">\u4e13\u7528\u670d\u52a1\u5668<\/a>\uff09\u7684 root \u6743\u9650\u65f6\uff0c\u624d\u5177\u5907\u5b8c\u6574\u8fc1\u79fb\u7684\u6761\u4ef6\uff0c<a href=\"https:\/\/cn.hostease.com\/vps\/\">Hostease VPS \u4e3b\u673a<\/a>\u8fd9\u7c7b\u72ec\u7acb\u73af\u5883\u5c31\u652f\u6301\u81ea\u7531\u66f4\u6362\u670d\u52a1\u5668\u8f6f\u4ef6\u3002<\/p>\n<h2>\u6838\u5fc3\u6b65\u9aa4\u4e00\uff1a\u865a\u62df\u4e3b\u673a\u4e0e\u91cd\u5199\u89c4\u5219\u7684\u7ffb\u8bd1<\/h2>\n<p>Apache \u7684\u914d\u7f6e\u4ee5 <code>&lt;VirtualHost&gt;<\/code> \u4e3a\u5355\u4f4d\uff1bNginx \u7528 <code>server {}<\/code> \u5757\u627f\u62c5\u540c\u6837\u89d2\u8272\u3002\u51e0\u4e2a\u6307\u4ee4\u540d\u5b57\u5b8c\u5168\u4e0d\u540c\uff0c\u9010\u9879\u5bf9\u7167\u53ef\u4ee5\u907f\u514d\u6f0f\u914d\uff0c\u8fc1\u79fb\u4e2d\u6700\u5e38\u89c1\u7684\u56db\u5904\u5bf9\u5e94\u5173\u7cfb\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><code>&lt;VirtualHost *:80&gt;<\/code> \u91cc\u7684 <code>ServerName<\/code> \u548c <code>ServerAlias<\/code> \u2192 <code>server {}<\/code> \u5757\u7684 <code>server_name<\/code>\uff0c\u591a\u4e2a\u57df\u540d\u7528\u7a7a\u683c\u5206\u9694<\/li>\n<li><code>DocumentRoot \/var\/www\/site<\/code> \u2192 <code>server {}<\/code> \u5757\u91cc\u7684 <code>root \/var\/www\/site;<\/code>\uff0c\u5168\u5c40\u5199\u4e00\u6b21\u5373\u53ef\uff0c\u4e0d\u5fc5\u6bcf\u4e2a location \u91cd\u590d<\/li>\n<li><code>AllowOverride All<\/code> \u542f\u7528\u7684 <code>.htaccess<\/code> \u2192 Nginx \u5b8c\u5168\u6ca1\u6709\u8fd9\u4e2a\u673a\u5236\uff0c\u89c4\u5219\u8981\u624b\u5199\u8fdb <code>server {}<\/code> \u6216\u5bf9\u5e94\u7684 <code>location {}<\/code><\/li>\n<li><code>ErrorLog<\/code> \/ <code>CustomLog<\/code> \u2192 <code>error_log<\/code> \u548c <code>access_log<\/code>\uff0c\u8def\u5f84\u548c\u683c\u5f0f\u53c2\u6570\u5199\u6cd5\u4e0d\u540c\u4f46\u529f\u80fd\u4e00\u81f4<\/li>\n<\/ul>\n<p>\u91cd\u5199\u89c4\u5219\u662f\u8fc1\u79fb\u5de5\u4f5c\u91cf\u6700\u5927\u7684\u90e8\u5206\uff0c<code>RewriteRule<\/code> \u8bed\u6cd5\u4e0d\u80fd\u76f4\u63a5\u590d\u5236\u5230 Nginx\uff0c\u8981\u6309\u8bed\u4e49\u91cd\u5199\u3002\u4ee5 WordPress \u56fa\u5b9a\u94fe\u63a5\u4e3a\u4f8b\uff0cApache \u5728 <code>.htaccess<\/code> \u91cc\u8981\u5199\u4e03\u516b\u884c\uff0cNginx \u6536\u655b\u6210\u4e00\u6761\uff1a<\/p>\n<pre><code class=\"language-nginx\">location \/ {\n    try_files $uri $uri\/ \/index.php?$args;\n}\n<\/code><\/pre>\n<p>\u8fd9\u6761\u914d\u7f6e\u7684\u542b\u4e49\u662f\u5148\u627e\u771f\u5b9e\u6587\u4ef6\uff0c\u518d\u627e\u76ee\u5f55\uff0c\u6700\u540e\u628a\u8bf7\u6c42\u4ea4\u7ed9 <code>index.php<\/code>\u300290% \u7684&#8221;\u8fc1\u79fb\u540e\u5168\u7ad9 404&#8243;\u90fd\u662f\u91cd\u5199\u89c4\u5219\u6ca1\u7ffb\u8bd1\u5bf9\u5bfc\u81f4\u7684\u3002WordPress \u7ad9\u70b9\u53ef\u4ee5\u53c2\u8003\u8fd9\u7bc7\u90e8\u7f72\u6559\u7a0b\u7684\u89c4\u5219\u90e8\u5206\uff1a<a href=\"https:\/\/cn.hostease.com\/blog\/wordpress\/\">WordPress \u670d\u52a1\u5668\u90e8\u7f72\u6559\u7a0b<\/a>\uff0c\u540c\u6837\u6309 <code>try_files<\/code> \u601d\u8def\u7ec4\u7ec7\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/10\/apache-to-nginx-architecture.webp\" alt=\"Apache \u4e0e Nginx \u67b6\u6784\u5c42\u6b21\u5bf9\u6bd4\u793a\u610f\u56fe\" loading=\"lazy\" \/><\/p>\n<h2>\u6838\u5fc3\u6b65\u9aa4\u4e8c\uff1aPHP \u5904\u7406\u65b9\u5f0f\u7684\u8854\u63a5<\/h2>\n<p>Apache \u901a\u5e38\u7528 <code>mod_php<\/code> \u628a PHP \u89e3\u91ca\u5668\u5185\u5d4c\u8fdb\u81ea\u8eab\u8fdb\u7a0b\uff1bNginx \u4e0d\u5904\u7406 PHP\uff0c\u800c\u662f\u628a\u52a8\u6001\u8bf7\u6c42\u7ecf FastCGI \u8f6c\u53d1\u7ed9\u72ec\u7acb\u7684 PHP-FPM \u8fdb\u7a0b\u6c60\u3002\u8fd9\u6b63\u662f Nginx \u66f4\u7701\u5185\u5b58\u7684\u539f\u56e0\u4e4b\u4e00\uff1a\u9759\u6001\u8bf7\u6c42\u5b8c\u5168\u4e0d\u78b0 PHP \u8fd0\u884c\u65f6\u3002<\/p>\n<p>\u8fc1\u79fb\u65f6\u9700\u8981\u5728 Nginx \u914d\u7f6e\u91cc\u663e\u5f0f\u58f0\u660e\u52a8\u6001\u8bf7\u6c42\u7684\u8f6c\u53d1\u89c4\u5219\uff1a<\/p>\n<pre><code class=\"language-nginx\">location ~ \\.php$ {\n    include snippets\/fastcgi-php.conf;\n    fastcgi_pass unix:\/run\/php\/php8.2-fpm.sock;\n}\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u6709\u4e24\u4e2a\u53c2\u6570\u5fc5\u987b\u6838\u5bf9\uff1a\u4e00\u662f socket \u8def\u5f84\u8981\u548c <code>php-fpm.conf<\/code> \u91cc <code>listen<\/code> \u7684\u503c\u4e00\u81f4\uff0c\u7248\u672c\u53f7\u4e0d\u540c\u53d1\u884c\u7248\u5dee\u5f02\u5f88\u5927\uff1b\u4e8c\u662f <code>php-fpm<\/code> \u8fdb\u7a0b\u6c60\u7684 <code>pm.max_children<\/code> \u8981\u6309\u5185\u5b58\u91cd\u65b0\u8ba1\u7b97\uff0c\u7c97\u7565\u516c\u5f0f\u662f\u53ef\u7528\u5185\u5b58\u9664\u4ee5\u5355\u4e2a PHP \u8fdb\u7a0b\u5cf0\u503c\u5185\u5b58\u3002\u6bd4\u5982\u7ed9 PHP-FPM \u5212\u5206 2GB\uff0c\u5355\u4e2a\u8fdb\u7a0b\u5cf0\u503c 60MB\uff0c<code>pm.max_children<\/code> \u5c31\u4e0d\u8981\u8bbe\u8d85\u8fc7 30\uff0c\u5426\u5219\u9ad8\u5e76\u53d1\u65f6\u4f1a\u89e6\u53d1 OOM\uff08\u5185\u5b58\u8017\u5c3d\uff09\u53cd\u800c\u62d6\u57ae\u6574\u673a\u3002<\/p>\n<p>\u9664\u8fd9\u4e24\u5904\uff0c\u8fd8\u6709\u4e09\u7c7b\u9ad8\u9891\u7ffb\u8bd1\u9519\u8bef\u8981\u6392\u67e5\u3002\u4e00\u662f\u76ee\u5f55\u7ea7\u914d\u7f6e\uff1aNginx \u6ca1\u6709 <code>.htaccess<\/code> \u7b49\u4ef7\u673a\u5236\uff0c\u8fc1\u79fb\u524d\u8981\u7528 <code>grep -r \"RewriteRule\" --include=\".htaccess\" \/var\/www<\/code> \u626b\u51fa\u6240\u6709\u6563\u843d\u89c4\u5219\uff0c\u9010\u4efd\u5408\u5e76\u8fdb\u4e3b\u914d\u7f6e\uff0c\u6f0f\u4e00\u4efd\u5c31\u4f1a\u51fa\u73b0&#8221;\u90e8\u5206\u9875\u9762\u6b63\u5e38\u3001\u90e8\u5206\u9875\u9762 404&#8243;\u3002\u4e8c\u662f\u8bbf\u95ee\u63a7\u5236\uff1aApache \u7684 <code>&lt;Directory&gt;<\/code> \u52a0 <code>Require ip<\/code> \u5bf9\u5e94 Nginx \u7684 <code>location {}<\/code> \u52a0 <code>allow<\/code>\/<code>deny<\/code>\uff0c\u4e14 <code>allow<\/code> \u5fc5\u987b\u5199\u5728 <code>deny all<\/code> \u4e4b\u524d\u3002\u4e09\u662f\u8d85\u65f6\u4e0e\u4e0a\u4f20\u9650\u5236\uff1a<code>.htaccess<\/code> \u91cc\u7684 <code>php_value<\/code> \u8bbe\u7f6e\u8981\u632a\u5230 <code>php-fpm.conf<\/code> \u6216 <code>fastcgi_read_timeout<\/code>\uff0c<code>upload_max_filesize<\/code> \u4e5f\u8981\u540c\u6b65\uff0c\u5426\u5219\u5927\u6587\u4ef6\u4e0a\u4f20\u4f1a\u9759\u9ed8\u5931\u8d25\u3002<\/p>\n<p>\u8fc1\u79fb\u5b8c\u6210\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u53ea\u542b <code>phpinfo();<\/code> \u7684\u4e34\u65f6\u6587\u4ef6\uff08\u5982 <code>check.php<\/code>\uff09\u9a8c\u8bc1 PHP \u7248\u672c\u3001\u6269\u5c55\u548c <code>php.ini<\/code> \u8def\u5f84\u662f\u5426\u4e0e\u8fc1\u79fb\u524d\u4e00\u81f4\uff0c\u786e\u8ba4\u540e\u7acb\u5373\u5220\u9664\uff0c\u907f\u514d\u6cc4\u9732\u670d\u52a1\u5668\u4fe1\u606f\u3002<\/p>\n<h2>\u8fc1\u79fb\u540e\u7684\u6027\u80fd\u9a8c\u8bc1\uff1a\u7528\u6570\u636e\u8bf4\u8bdd<\/h2>\n<p>\u6027\u80fd\u63d0\u5347\u4e0d\u80fd\u9760\u611f\u89c9\u5224\u65ad\uff0c\u8981\u7528\u8fc1\u79fb\u524d\u540e\u540c\u4e00\u53e3\u5f84\u7684\u538b\u6d4b\u6570\u636e\u5bf9\u6bd4\u3002\u63a8\u8350\u5206\u4e09\u6b65\u9a8c\u8bc1\uff1a<\/p>\n<ol>\n<li>\u8fc1\u79fb\u524d\u5728 Apache \u4e0a\u538b\u6d4b\u4e00\u8f6e\u5e76\u8bb0\u5f55\u57fa\u7ebf\uff1a<code>ab -n 2000 -c 100 https:\/\/\u4f60\u7684\u57df\u540d\/<\/code>\uff0c\u91cd\u70b9\u8bb0\u5f55\u6bcf\u79d2\u8bf7\u6c42\u6570\uff08Requests per second\uff09\u548c 95 \u5206\u4f4d\u54cd\u5e94\u65f6\u95f4<\/li>\n<li>\u5207\u6362\u5230 Nginx \u540e\u7528\u5b8c\u5168\u76f8\u540c\u7684\u547d\u4ee4\u518d\u538b\u4e00\u8f6e\uff0c\u73af\u5883\uff08CPU\u3001\u5185\u5b58\u3001\u7f51\u7edc\u3001\u6570\u636e\u5e93\uff09\u4fdd\u6301\u4e0d\u53d8\uff0c\u53ea\u5bf9\u6bd4\u670d\u52a1\u5668\u8f6f\u4ef6\u8fd9\u4e00\u4e2a\u53d8\u91cf<\/li>\n<li>\u7528 <code>curl -w<\/code> \u62bd\u67e5\u5173\u952e\u9875\u9762\u7684\u5206\u89e3\u8017\u65f6\uff0c\u786e\u8ba4\u9996\u5b57\u8282\u65f6\u95f4\u6ca1\u6709\u52a3\u5316<\/li>\n<\/ol>\n<p>\u9664\u538b\u6d4b\u5916\uff0c\u751f\u4ea7\u6307\u6807\u540c\u6837\u91cd\u8981\uff1a\u8fc1\u79fb\u540e\u89c2\u5bdf 3-7 \u5929\u7684\u5185\u5b58\u66f2\u7ebf\uff0cNginx \u65b9\u6848\u5e94\u660e\u663e\u4f4e\u4e8e\u8fc1\u79fb\u524d\u4e14\u5e73\u7a33\uff1b\u540c\u65f6\u5728\u8bbf\u95ee\u65e5\u5fd7\u91cc\u7edf\u8ba1 5xx \u9519\u8bef\u7387\uff0c\u786e\u8ba4\u914d\u7f6e\u7ffb\u8bd1\u6ca1\u6709\u9057\u6f0f\u3002\u66f4\u591a\u8c03\u4f18\u7ecf\u9a8c\u53ef\u7ffb\u9605<a href=\"https:\/\/cn.hostease.com\/blog\/server\/\">\u670d\u52a1\u5668\u4f18\u5316\u4e13\u9898<\/a>\u3002<\/p>\n<h2>\u5e38\u89c1\u8fc1\u79fb\u9677\u9631\u4e0e\u6392\u67e5\u601d\u8def<\/h2>\n<p>\u8fc1\u79fb\u5b8c\u6210\u540e\u5934\u51e0\u5929\uff0c\u6709\u51e0\u7c7b\u95ee\u9898\u6700\u5e38\u5192\u51fa\u6765\uff0c\u63d0\u524d\u77e5\u9053\u6392\u67e5\u65b9\u5411\u53ef\u4ee5\u7701\u6389\u5927\u91cf\u6478\u7d22\u65f6\u95f4\u3002<\/p>\n<p>\u7b2c\u4e00\u7c7b\u662f\u6df7\u5408\u5185\u5bb9\u544a\u8b66\uff1a\u9875\u9762\u80fd\u6253\u5f00\u4f46\u6d4f\u89c8\u5668\u63d0\u793a\u4e0d\u5b89\u5168\uff0c\u901a\u5e38\u662f\u6a21\u677f\u91cc\u5199\u6b7b\u4e86 http:\/\/ \u5f00\u5934\u7684\u8d44\u6e90\u5730\u5740\uff0c\u7528 <code>curl<\/code> \u6293\u53d6\u9996\u9875\u518d\u914d\u5408 <code>grep<\/code> \u8fc7\u6ee4\u51fa\u6240\u6709\u975e\u52a0\u5bc6\u5f15\u7528\uff0c\u9010\u6761\u6539\u6210\u76f8\u5bf9\u8def\u5f84\u6216 https \u5373\u53ef\u3002<\/p>\n<p>\u7b2c\u4e8c\u7c7b\u662f\u4f1a\u8bdd\u53cd\u590d\u6389\u7ebf\uff1a\u5728 fastcgi \u53c2\u6570\u91cc\u8865\u4e0a <code>fastcgi_param HTTPS on;<\/code>\uff0c\u786e\u8ba4 <code>$_SERVER['HTTPS']<\/code> \u53d6\u503c\u6b63\u786e\u5373\u53ef\u6062\u590d\u3002<\/p>\n<p>\u7b2c\u4e09\u7c7b\u662f 502 \u96c6\u4e2d\u51fa\u73b0\uff1a\u901a\u5e38\u662f PHP-FPM \u8fdb\u7a0b\u8017\u5c3d\uff0c\u786e\u8ba4 <code>php-fpm.log<\/code> \u91cc\u7684 max_children \u8bb0\u5f55\u540e\uff0c\u8c03\u5927\u8fdb\u7a0b\u6c60\u6216\u8ba9\u8fdb\u7a0b\u5b9a\u671f\u56de\u6536\u3002<\/p>\n<p>\u628a\u8fd9\u4e09\u7c7b\u6392\u67e5\u52a8\u4f5c\u5199\u8fdb\u8fd0\u7ef4\u624b\u518c\uff0c\u4e0b\u6b21\u7ad9\u70b9\u8fc1\u79fb\u5c31\u80fd\u6309\u56fe\u7d22\u9aa5\u3002<\/p>\n<h2>\u56de\u6eda\u65b9\u6848\u4e0e\u603b\u7ed3<\/h2>\n<p>\u518d\u987a\u5229\u7684\u8fc1\u79fb\u4e5f\u8981\u51c6\u5907\u9000\u8def\u3002\u6700\u7a33\u59a5\u7684\u505a\u6cd5\u662f\u5207\u6362\u671f\u95f4\u4e0d\u5378\u8f7d Apache\uff1a\u4e24\u4e2a\u8f6f\u4ef6\u76d1\u542c\u4e0d\u540c\u7aef\u53e3\u5171\u5b58\uff08Nginx \u7528 80\/443\uff0cApache \u6539 8080\uff09\uff0c\u4fdd\u7559 <code>.htaccess<\/code> \u548c\u539f\u914d\u7f6e\u4e0d\u5220\uff0cDNS\uff08\u57df\u540d\u89e3\u6790\uff09\u6216\u8d1f\u8f7d\u5747\u8861\u53ef\u968f\u65f6\u628a\u6d41\u91cf\u5207\u56de\u3002\u56de\u6eda\u524d\u5148\u5728 8080 \u7aef\u53e3\u9a8c\u8bc1 Apache \u6b63\u5e38\uff0c\u518d\u5207\u6d41\u91cf\uff0c\u56de\u9000\u53ef\u63a7\u5236\u5728\u51e0\u5206\u949f\u5185\u3002<\/p>\n<p>\u603b\u7ed3\u4e00\u4e0b\u5b8c\u6574\u8fc1\u79fb\u8def\u5f84\uff1a\u5148\u7406\u89e3\u8fde\u63a5\u5904\u7406\u6a21\u578b\u5dee\u5f02\uff0c\u518d\u7ffb\u8bd1\u865a\u62df\u4e3b\u673a\u548c\u91cd\u5199\u89c4\u5219\uff0c\u63a5\u7740\u8854\u63a5 PHP-FPM\uff0c\u6700\u540e\u7528\u540c\u4e00\u53e3\u5f84\u538b\u6d4b\u6570\u636e\u9a8c\u8bc1\u6536\u76ca\u3002\u5982\u679c\u4f60\u9700\u8981\u4e00\u53f0\u53ef\u81ea\u7531\u66f4\u6362\u670d\u52a1\u5668\u8f6f\u4ef6\u7684\u72ec\u7acb\u73af\u5883\u6765\u5b9e\u8df5\u8fd9\u5957\u6d41\u7a0b\uff0c\u53ef\u4ee5\u8003\u8651<a href=\"https:\/\/cn.hostease.com\/vps\/\">Hostease VPS \u4e3b\u673a<\/a>\uff0croot \u6743\u9650\u5b8c\u6574\uff0c\u5907\u4efd\u3001\u5207\u6362\u5230\u56de\u6eda\u90fd\u7531\u4f60\u638c\u63a7\u8282\u594f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u624b\u628a\u624b\u6559\u4f60\u5b8c\u6210 Apache \u5230 Nginx \u7684\u8fc1\u79fb\uff1a\u865a\u62df\u4e3b\u673a\u3001\u91cd\u5199\u89c4\u5219\u3001PHP \u5904\u7406\u65b9\u5f0f\u5982\u4f55\u8f6c\u6362\uff0c\u8fc1\u79fb\u524d\u540e\u6027\u80fd\u5dee\u5f02\u600e\u4e48\u9a8c\u8bc1\uff0c\u9644\u5b8c\u6574\u914d\u7f6e\u5bf9\u7167\u4e0e\u56de\u6eda\u65b9\u6848\u3002<\/p>\n","protected":false},"author":2,"featured_media":32439,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4099],"tags":[1712,393,4317,2771,5404],"class_list":["post-34078","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-apache","tag-nginx","tag-web","tag-2771","tag-5404"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/cn.hostease.com\/blog\/wp-content\/uploads\/2026\/08\/apache-to-nginx-migration-cover.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/34078","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/comments?post=34078"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/34078\/revisions"}],"predecessor-version":[{"id":34088,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/posts\/34078\/revisions\/34088"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media\/32439"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/media?parent=34078"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/categories?post=34078"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/blog\/wp-json\/wp\/v2\/tags?post=34078"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}