{"id":230068,"date":"2023-12-25T14:22:27","date_gmt":"2023-12-25T06:22:27","guid":{"rendered":"https:\/\/www.idc.net\/help\/230068\/"},"modified":"2023-12-25T14:22:27","modified_gmt":"2023-12-25T06:22:27","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8apache%e5%92%8cphp","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/230068\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528Apache\u548cPHP"},"content":{"rendered":"<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8apache%e5%92%8cphp-PEAYrjXEuq\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528Apache\u548cPHP<\/h1>\n<p>Apache\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5f00\u6e90Web\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\uff0c\u5e76\u4e14\u4e0ePHP\u8bed\u8a00\u7684\u7ed3\u5408\u4f7f\u7528\u975e\u5e38\u5e7f\u6cdb\u3002\u672c\u6559\u7a0b\u5c06\u5411\u60a8\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Apache\u548cPHP\u6765\u642d\u5efa\u548c\u7ba1\u7406\u60a8\u81ea\u5df1\u7684\u7f51\u7ad9\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afapache%ef%bc%9f-PEAYrjXEuq\">\u4ec0\u4e48\u662fApache\uff1f<\/h2>\n<p>Apache\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684Web\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u5b83\u662f\u7531Apache\u8f6f\u4ef6\u57fa\u91d1\u4f1a\u5f00\u53d1\u548c\u7ef4\u62a4\u7684\u3002Apache\u662f\u6700\u6d41\u884c\u7684Web\u670d\u52a1\u5668\u8f6f\u4ef6\u4e4b\u4e00\uff0c\u5b83\u53ef\u4ee5\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\uff0c\u5305\u62ecWindows\u3001Linux\u548cMac OS\u3002<\/p>\n<p>Apache\u7684\u4e3b\u8981\u529f\u80fd\u662f\u63a5\u6536\u6765\u81ea\u5ba2\u6237\u7aef\u7684HTTP\u8bf7\u6c42\uff0c\u5e76\u5c06\u76f8\u5e94\u7684\u7f51\u9875\u5185\u5bb9\u53d1\u9001\u56de\u5ba2\u6237\u7aef\u3002\u5b83\u652f\u6301\u5404\u79cd\u529f\u80fd\u548c\u6a21\u5757\uff0c\u53ef\u4ee5\u7528\u4e8e\u6784\u5efa\u5404\u79cd\u7c7b\u578b\u7684\u7f51\u7ad9\uff0c\u5305\u62ec\u9759\u6001\u7f51\u9875\u3001\u52a8\u6001\u7f51\u9875\u548c\u7535\u5b50\u5546\u52a1\u7f51\u7ad9\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%85apache-PEAYrjXEuq\">\u5b89\u88c5Apache<\/h2>\n<p>\u5728\u5f00\u59cb\u4f7f\u7528Apache\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5148\u5b89\u88c5\u5b83\u3002\u4ee5\u4e0b\u662f\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5Apache\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u8bbf\u95eeApache\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/httpd.apache.org\/\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/httpd.apache.org\/<\/a>\uff09\u3002<\/li>\n<li>\u4e0b\u8f7d\u9002\u7528\u4e8eWindows\u7684\u6700\u65b0\u7248\u672c\u7684Apache\u3002<\/li>\n<li>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li>\u5b8c\u6210\u5b89\u88c5\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5f00\u59cb\u83dc\u5355\u4e2d\u627e\u5230Apache\u7684\u542f\u52a8\u7a0b\u5e8f\u3002<\/li>\n<\/ol>\n<p>\u5728Linux\u548cMac OS\u4e0a\u5b89\u88c5Apache\u7684\u6b65\u9aa4\u7565\u6709\u4e0d\u540c\uff0c\u60a8\u53ef\u4ee5\u5728Apache\u5b98\u65b9\u7f51\u7ad9\u4e0a\u627e\u5230\u76f8\u5e94\u7684\u5b89\u88c5\u6307\u5357\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%aeapache-PEAYrjXEuq\">\u914d\u7f6eApache<\/h2>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u9700\u8981\u5bf9Apache\u8fdb\u884c\u4e00\u4e9b\u914d\u7f6e\uff0c\u4ee5\u4fbf\u5b83\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u5e76\u4e0ePHP\u8bed\u8a00\u7ed3\u5408\u4f7f\u7528\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u914d\u7f6e\u4efb\u52a1\uff1a<\/p>\n<h3 id=\"%e9%85%8d%e7%bd%ae%e7%bd%91%e7%ab%99%e6%a0%b9%e7%9b%ae%e5%bd%95-PEAYrjXEuq\">\u914d\u7f6e\u7f51\u7ad9\u6839\u76ee\u5f55<\/h3>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cApache\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\u4f4d\u4e8e\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\u201chtdocs\u201d\u6587\u4ef6\u5939\u4e2d\u3002\u60a8\u53ef\u4ee5\u5c06\u60a8\u7684\u7f51\u7ad9\u6587\u4ef6\u653e\u5728\u8be5\u6587\u4ef6\u5939\u4e2d\uff0c\u6216\u8005\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\u6765\u6307\u5b9a\u5176\u4ed6\u76ee\u5f55\u4f5c\u4e3a\u7f51\u7ad9\u6839\u76ee\u5f55\u3002<\/p>\n<p>\u8981\u4fee\u6539\u7f51\u7ad9\u6839\u76ee\u5f55\uff0c\u60a8\u9700\u8981\u7f16\u8f91Apache\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u5728Windows\u4e0a\uff0c\u8be5\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684\u201cconf\u201d\u6587\u4ef6\u5939\u4e2d\u7684\u201chttpd.conf\u201d\u6587\u4ef6\u3002\u5728Linux\u548cMac OS\u4e0a\uff0c\u8be5\u6587\u4ef6\u901a\u5e38\u4f4d\u4e8e\u201c\/etc\/apache2\/\u201d\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/p>\n<p><code>DocumentRoot \"C:\/Apache\/htdocs\"<\/code><\/p>\n<p>\u5c06\u5176\u4fee\u6539\u4e3a\u60a8\u60f3\u8981\u7684\u76ee\u5f55\u8def\u5f84\uff1a<\/p>\n<p><code>DocumentRoot \"C:\/path\/to\/your\/website\"<\/code><\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u91cd\u542fApache\uff0c\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<h3 id=\"%e5%90%af%e7%94%a8php%e6%a8%a1%e5%9d%97-PEAYrjXEuq\">\u542f\u7528PHP\u6a21\u5757<\/h3>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cApache\u4e0d\u4f1a\u542f\u7528PHP\u6a21\u5757\u3002\u8981\u542f\u7528PHP\u6a21\u5757\uff0c\u60a8\u9700\u8981\u7f16\u8f91Apache\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/p>\n<p><code>#LoadModule php7_module modules\/libphp7.so<\/code><\/p>\n<p>\u5c06\u5176\u4fee\u6539\u4e3a\uff1a<\/p>\n<p><code>LoadModule php7_module modules\/libphp7.so<\/code><\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\u5e76\u91cd\u542fApache\uff0c\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8apache%e5%92%8cphp-PEAYrjXEuq\">\u4f7f\u7528Apache\u548cPHP<\/h2>\n<p>\u4e00\u65e6\u60a8\u5b8c\u6210\u4e86Apache\u548cPHP\u7684\u5b89\u88c5\u548c\u914d\u7f6e\uff0c\u60a8\u5c31\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528\u5b83\u4eec\u6765\u642d\u5efa\u548c\u7ba1\u7406\u60a8\u7684\u7f51\u7ad9\u4e86\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u6587\u672c\u7f16\u8f91\u5668\u6765\u521b\u5efa\u60a8\u7684\u7f51\u9875\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u5176\u4fdd\u5b58\u5230Apache\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\u4e2d\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528HTML\u548cPHP\u8bed\u8a00\u6765\u7f16\u5199\u60a8\u7684\u7f51\u9875\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<p><code>&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;\u6211\u7684\u7f51\u7ad9&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;h1&gt;\u6b22\u8fce\u8bbf\u95ee\u6211\u7684\u7f51\u7ad9\uff01&lt;\/h1&gt;<br \/>\n&lt;?php<br \/>\necho \"Hello, World!\";<br \/>\n?&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/code><\/p>\n<p>\u4fdd\u5b58\u6587\u4ef6\u4e3a\u201cindex.php\u201d\uff0c\u7136\u540e\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u60a8\u7684\u7f51\u7ad9\uff0c\u60a8\u5c06\u770b\u5230\u4e00\u4e2a\u5305\u542b\u201c\u6b22\u8fce\u8bbf\u95ee\u6211\u7684\u7f51\u7ad9\uff01\u201d\u548c\u201cHello, World!\u201d\u7684\u9875\u9762\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-PEAYrjXEuq\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u672c\u6559\u7a0b\uff0c\u60a8\u4e86\u89e3\u4e86\u5982\u4f55\u4f7f\u7528Apache\u548cPHP\u6765\u642d\u5efa\u548c\u7ba1\u7406\u60a8\u81ea\u5df1\u7684\u7f51\u7ad9\u3002Apache\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5f00\u6e90Web\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u3002\u5b89\u88c5\u548c\u914d\u7f6eApache\u975e\u5e38\u7b80\u5355\uff0c\u60a8\u53ea\u9700\u8981\u6309\u7167\u5b98\u65b9\u6307\u5357\u8fdb\u884c\u64cd\u4f5c\u5373\u53ef\u3002\u4e00\u65e6\u5b89\u88c5\u548c\u914d\u7f6e\u5b8c\u6210\uff0c\u60a8\u5c31\u53ef\u4ee5\u4f7f\u7528Apache\u548cPHP\u6765\u521b\u5efa\u5404\u79cd\u7c7b\u578b\u7684\u7f51\u7ad9\u3002<\/p>\n<p>\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91\uff0c\u63d0\u4f9b\u7a33\u5b9a\u53ef\u9760\u7684\u670d\u52a1\u5668\u6258\u7ba1\u670d\u52a1\u3002\u60a8\u53ef\u4ee5\u8bbf\u95ee<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a>\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528Apache\u548cPHP Apache\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5f00\u6e90Web\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u5404\u79cd\u64cd\u4f5c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-230068","post","type-post","status-publish","format-standard","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/230068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=230068"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/230068\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=230068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=230068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=230068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}