{"id":54295,"date":"2024-10-09T18:15:16","date_gmt":"2024-10-09T10:15:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/54295\/"},"modified":"2024-10-09T18:15:16","modified_gmt":"2024-10-09T10:15:16","slug":"windows-%e4%b8%8b-apache-%e6%87%89%e7%94%a8%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/54295\/","title":{"rendered":"Windows \u4e0b Apache \u61c9\u7528\u74b0\u5883\u642d\u5efa\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"windows-%e4%b8%8b-apache-%e6%87%89%e7%94%a8%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba%e6%96%b9%e6%b3%95-XthBVdtwSJ\">Windows \u4e0b Apache \u61c9\u7528\u74b0\u5883\u642d\u5efa\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cApache \u4f5c\u70ba\u4e00\u500b\u958b\u6e90\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u5e73\u53f0\u4e0a\u3002\u96d6\u7136\u5927\u591a\u6578\u4eba\u7fd2\u6163\u65bc\u5728 Linux \u74b0\u5883\u4e2d\u4f7f\u7528 Apache\uff0c\u4f46\u5728 Windows \u7cfb\u7d71\u4e0a\u642d\u5efa Apache \u74b0\u5883\u540c\u6a23\u662f\u53ef\u884c\u7684\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 Windows \u4e0b\u642d\u5efa Apache \u61c9\u7528\u74b0\u5883\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u6b65\u9a5f\u548c\u5efa\u8b70\u3002<\/p>\n<h2 id=\"1-%e4%b8%8b%e8%bc%89-apache-XthBVdtwSJ\">1. \u4e0b\u8f09 Apache<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5f9e Apache \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u9069\u5408 Windows \u7684 Apache \u5b89\u88dd\u5305\u3002\u53ef\u4ee5\u8a2a\u554f <a href=\"https:\/\/httpd.apache.org\/download.cgi\" rel=\"nofollow noopener\" target=\"_blank\">Apache HTTP Server Project<\/a> \u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 Apache\u3002\u9078\u64c7 Windows \u7248\u672c\u7684\u4e8c\u9032\u5236\u6587\u4ef6\uff0c\u901a\u5e38\u662f\u4ee5 .msi \u6216 .zip \u683c\u5f0f\u63d0\u4f9b\u3002<\/p>\n<h2 id=\"2-%e5%ae%89%e8%a3%9d-apache-XthBVdtwSJ\">2. \u5b89\u88dd Apache<\/h2>\n<p>\u5982\u679c\u60a8\u4e0b\u8f09\u7684\u662f .msi \u6587\u4ef6\uff0c\u96d9\u64ca\u8a72\u6587\u4ef6\u958b\u59cb\u5b89\u88dd\u3002\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u60a8\u9700\u8981\u9078\u64c7\u5b89\u88dd\u76ee\u9304\uff0c\u5efa\u8b70\u9078\u64c7\u4e00\u500b\u7c21\u55ae\u7684\u8def\u5f91\uff0c\u4f8b\u5982 C:Apache24\u3002\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u60a8\u9084\u9700\u8981\u8a2d\u7f6e\u670d\u52d9\u540d\u7a31\u548c\u7aef\u53e3\u865f\uff0c\u9ed8\u8a8d\u60c5\u6cc1\u4e0b\uff0cApache \u4f7f\u7528 80 \u7aef\u53e3\u3002<\/p>\n<h2 id=\"3-%e9%85%8d%e7%bd%ae-apache-XthBVdtwSJ\">3. \u914d\u7f6e Apache<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u5c0d Apache \u9032\u884c\u57fa\u672c\u914d\u7f6e\u3002\u6253\u958b\u5b89\u88dd\u76ee\u9304\u4e0b\u7684 <code>conf\/httpd.conf<\/code> \u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7de8\u8f2f\u5668\u9032\u884c\u7de8\u8f2f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u914d\u7f6e\u9805\uff1a<\/p>\n<ul>\n<li><strong>DocumentRoot<\/strong>: \u8a2d\u7f6e\u7db2\u7ad9\u6839\u76ee\u9304\uff0c\u4f8b\u5982\uff1a<code>DocumentRoot \"C:\/Apache24\/htdocs\"<\/code><\/li>\n<li><strong>Directory<\/strong>: \u8a2d\u7f6e\u5c0d\u61c9\u7684\u76ee\u9304\u6b0a\u9650\uff0c\u4f8b\u5982\uff1a<\/li>\n<pre><code>&lt;Directory \"C:\/Apache24\/htdocs\"&gt;\n    Options Indexes FollowSymLinks\n    AllowOverride None\n    Require all granted\n    &lt;\/Directory&gt;<\/code><\/pre>\n<li><strong>Listen<\/strong>: \u78ba\u4fdd Apache \u76e3\u807d\u6b63\u78ba\u7684\u7aef\u53e3\uff0c\u4f8b\u5982\uff1a<code>Listen 80<\/code><\/li>\n<\/ul>\n<h2 id=\"4-%e5%95%9f%e5%8b%95-apache-XthBVdtwSJ\">4. \u555f\u52d5 Apache<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u555f\u52d5 Apache\u3002\u6253\u958b\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u9032\u5165 Apache \u7684 bin \u76ee\u9304\uff0c\u7136\u5f8c\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>httpd -k install\nhttpd -k start<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165 <code>http:\/\/localhost<\/code> \u4f86\u8a2a\u554f Apache \u7684\u9810\u8a2d\u9801\u9762\u3002<\/p>\n<h2 id=\"5-%e6%b8%ac%e8%a9%a6-apache-XthBVdtwSJ\">5. \u6e2c\u8a66 Apache<\/h2>\n<p>\u70ba\u4e86\u78ba\u4fdd Apache \u6b63\u5e38\u904b\u884c\uff0c\u60a8\u53ef\u4ee5\u5728 <code>htdocs<\/code> \u76ee\u9304\u4e2d\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684 HTML \u6587\u4ef6\uff0c\u4f8b\u5982 <code>index.html<\/code>\uff0c\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>&lt;html&gt;\n&lt;head&gt;&lt;title&gt;Hello, Apache!&lt;\/title&gt;&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;Welcome to Apache on Windows!&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u518d\u6b21\u8a2a\u554f <code>http:\/\/localhost\/index.html<\/code>\uff0c\u5982\u679c\u80fd\u770b\u5230\u60a8\u5275\u5efa\u7684\u9801\u9762\uff0c\u5247\u8868\u793a Apache \u5df2\u6210\u529f\u904b\u884c\u3002<\/p>\n<h2 id=\"6-%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-XthBVdtwSJ\">6. \u5e38\u898b\u554f\u984c\u53ca\u89e3\u6c7a\u65b9\u6848<\/h2>\n<p>\u5728\u642d\u5efa Apache \u74b0\u5883\u7684\u904e\u7a0b\u4e2d\uff0c\u60a8\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u5e38\u898b\u554f\u984c\uff1a<\/p>\n<ul>\n<li><strong>\u7aef\u53e3\u885d\u7a81<\/strong>: \u5982\u679c 80 \u7aef\u53e3\u88ab\u5176\u4ed6\u61c9\u7528\u4f54\u7528\uff0c\u60a8\u53ef\u4ee5\u5728 <code>httpd.conf<\/code> \u4e2d\u4fee\u6539 <code>Listen<\/code> \u7684\u7aef\u53e3\u865f\u3002<\/li>\n<li><strong>\u9632\u706b\u7246\u8a2d\u7f6e<\/strong>: \u78ba\u4fdd Windows \u9632\u706b\u7246\u5141\u8a31 Apache \u7684\u57f7\u884c\uff0c\u60a8\u53ef\u4ee5\u5728\u9632\u706b\u7246\u8a2d\u7f6e\u4e2d\u6dfb\u52a0\u4f8b\u5916\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-XthBVdtwSJ\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Windows \u4e0b\u642d\u5efa Apache \u74b0\u5883\u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u53ea\u9700\u4e0b\u8f09\u3001\u5b89\u88dd\u3001\u914d\u7f6e\u548c\u555f\u52d5\u5373\u53ef\u3002\u9019\u70ba\u958b\u767c\u548c\u6e2c\u8a66\u63d0\u4f9b\u4e86\u4fbf\u5229\u7684\u74b0\u5883\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u7db2\u7ad9\u63d0\u4f9b\u66f4\u7a69\u5b9a\u7684\u6027\u80fd\u548c\u66f4\u597d\u7684\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728 Windows \u7cfb\u7d71\u4e0a\u642d\u5efa Apache \u61c9\u7528\u74b0\u5883\uff0c\u7c21\u55ae\u6b65\u9a5f\u52a9\u4f60\u5feb\u901f\u914d\u7f6e\u4f3a\u670d\u5668\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-54295","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/54295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=54295"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/54295\/revisions"}],"predecessor-version":[{"id":54296,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/54295\/revisions\/54296"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=54295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=54295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=54295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}