{"id":264555,"date":"2024-05-15T15:41:28","date_gmt":"2024-05-15T07:41:28","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/264555.html"},"modified":"2024-05-15T15:41:33","modified_gmt":"2024-05-15T07:41:33","slug":"%e6%95%b4%e5%a5%97php%e6%ba%90%e4%bb%a3%e7%a0%81%e5%9c%a8%e6%9c%ac%e5%9c%b0%e6%80%8e%e4%b9%88%e6%b5%8b%e8%af%95%e8%bf%90%e8%a1%8c-3","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/264555.html","title":{"rendered":"\u6574\u5957php\u6e90\u4ee3\u7801\u5728\u672c\u5730\u600e\u4e48\u6d4b\u8bd5\u8fd0\u884c"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27125214\/bae23543-6589-4d15-b7a6-9cbe682702c0.webp\" alt=\"\u6574\u5957php\u6e90\u4ee3\u7801\u5728\u672c\u5730\u600e\u4e48\u6d4b\u8bd5\u8fd0\u884c\" \/><\/p>\n<p><p>PHP\u662f\u4e00\u79cd\u88ab\u5e7f\u6cdb\u4f7f\u7528\u7684\u5f00\u653e\u6e90\u4ee3\u7801\u7684\u670d\u52a1\u5668\u7aef\u811a\u672c\u8bed\u8a00\uff0c<strong>\u672c\u5730\u6d4b\u8bd5\u8fd0\u884c\u6574\u5957PHP\u6e90\u4ee3\u7801<\/strong>\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a<strong>\u786e\u4fddPHP\u73af\u5883\u5df2\u7ecf\u5b89\u88c5\u3001\u914d\u7f6eWeb\u670d\u52a1\u5668\uff08\u5982Apache\u6216Nginx\uff09\u3001\u4f7f\u7528\u6570\u636e\u5e93\uff08\u5982MySQL\uff09\u548c\u8bbe\u7f6e\u6b63\u786e\u7684\u6587\u4ef6\u6743\u9650\u3001\u6d4b\u8bd5\u8fd0\u884c<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u914d\u7f6eWeb\u670d\u52a1\u5668<\/strong>\u662f\u5176\u4e2d\u7684\u5173\u952e\u90e8\u5206\uff0c\u56e0\u4e3aPHP\u901a\u5e38\u9700\u8981\u4e00\u4e2a\u670d\u52a1\u5668\u6765\u89e3\u6790\u4ee3\u7801\u5e76\u663e\u793a\u5176\u751f\u6210\u7684\u5185\u5bb9\u3002Apache\u670d\u52a1\u5668\u662f\u6700\u5e38\u7528\u7684PHP\u5f00\u53d1\u73af\u5883\u4e4b\u4e00\uff0c\u5b83\u80fd\u591f\u5904\u7406PHP\u6587\u4ef6\u7684\u89e3\u6790\uff0c\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5728\u672c\u5730\u673a\u5668\u4e0a\u642d\u5efa\u4e00\u4e2a\u7c7b\u4f3c\u751f\u4ea7\u73af\u5883\u7684\u6d4b\u8bd5\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001PHP\u73af\u5883\u642d\u5efa<\/p>\n<p>\u5728\u6d4b\u8bd5PHP\u4ee3\u7801\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u7684\u7535\u8111\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86PHP\u3002\u4f60\u53ef\u4ee5\u4e0b\u8f7dPHP\u6e90\u4ee3\u7801\u5e76\u624b\u52a8\u5b89\u88c5\uff0c\u6216\u8005\u4f7f\u7528\u50cfXAMPP\u3001WampServer\u8fd9\u6837\u7684\u96c6\u6210\u5305\uff0c\u8fd9\u4e9b\u90fd\u5305\u542b\u4e86PHP\u3001\u6570\u636e\u5e93\u670d\u52a1\u5668\u4ee5\u53caWeb\u670d\u52a1\u5668\u3002\u5b89\u88c5\u5b8c\u6bd5\u4e4b\u540e\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u8f93\u5165 <code>php -v<\/code> \u6765\u68c0\u67e5PHP\u7248\u672c\uff0c\u786e\u8ba4\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5PHP\uff1a<\/strong><\/p>\n<p>\u5b89\u88c5PHP\u4e4b\u540e\uff0c\u9700\u8981\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u5bf9PHP\u8fdb\u884c\u73af\u5883\u53d8\u91cf\u7684\u914d\u7f6e\uff0c\u4ee5\u4fbf\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u90fd\u80fd\u8c03\u7528PHP\u547d\u4ee4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5e76\u914d\u7f6e\u670d\u52a1\u5668\uff1a<\/strong><\/p>\n<p>\u53ef\u4ee5\u9009\u62e9Apache\u6216Nginx\u4f5c\u4e3aWeb\u670d\u52a1\u5668\u3002\u8fd9\u4e9b\u670d\u52a1\u5668\u9700\u8981\u5bf9PHP\u4ee3\u7801\u8fdb\u884c\u89e3\u6790\u5e76\u6267\u884c\uff0c\u4ece\u800c\u5728\u6d4f\u89c8\u5668\u4e2d\u663e\u793a\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u914d\u7f6eWeb\u670d\u52a1\u5668<\/p>\n<p>Web\u670d\u52a1\u5668\u7684\u914d\u7f6e\u662f\u672c\u5730\u6d4b\u8bd5PHP\u4ee3\u7801\u7684\u4e00\u4e2a\u91cd\u70b9\u3002\u5bf9\u4e8eApache\uff0c\u901a\u5e38\u9700\u8981\u8bbe\u7f6e\u865a\u62df\u4e3b\u673a\u5e76\u786e\u4fdd<code>mod_php<\/code>\u6a21\u5757\u5df2\u7ecf\u542f\u7528\uff0c\u8fd9\u6837Apache\u624d\u80fd\u5904\u7406PHP\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8bbe\u7f6e\u865a\u62df\u4e3b\u673a\uff1a<\/strong><\/p>\n<p>\u901a\u8fc7\u7f16\u8f91Apache\u914d\u7f6e\u6587\u4ef6<code>httpd.conf<\/code>\u6216<code>httpd-vhosts.conf<\/code>\uff0c\u8bbe\u7f6e\u865a\u62df\u4e3b\u673a\u6765\u6307\u5411\u60a8\u7684\u672c\u5730\u9879\u76ee\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fee\u6539hosts\u6587\u4ef6\uff1a<\/strong><\/p>\n<p>\u5728\u672c\u5730\u8ba1\u7b97\u673a\u7684hosts\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u6761\u76ee\uff0c\u5c06\u6240\u9009\u62e9\u7684\u670d\u52a1\u5668\u540d\u6620\u5c04\u5230\u672c\u5730\u5730\u5740127.0.0.1\uff0c\u8fd9\u6837\u4fbf\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u4f7f\u7528\u8be5\u670d\u52a1\u5668\u540d\u6765\u8bbf\u95ee\u672c\u5730\u9879\u76ee\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u6570\u636e\u5e93\u914d\u7f6e<\/p>\n<p>\u5982\u679c\u6e90\u4ee3\u7801\u4e2d\u5305\u542b\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u90e8\u5206\uff0c\u5219\u9700\u8981\u5728\u672c\u5730\u5b89\u88c5\u548c\u914d\u7f6e\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u6bd4\u5982MySQL\u3002\u521b\u5efa\u6570\u636e\u5e93\u3001\u5bfc\u5165\u6570\u636e\u3001\u914d\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u662f\u8fd9\u90e8\u5206\u7684\u6838\u5fc3\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u6570\u636e\u5e93\uff1a<\/strong><\/p>\n<p>\u5b89\u88c5MySQL\u6216\u5176\u4ed6\u6570\u636e\u5e93\u670d\u52a1\u5668\uff0c\u5e76\u786e\u4fdd\u5b83\u5728\u672c\u5730\u8fd0\u884c\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u754c\u9762\u6216\u56fe\u5f62\u754c\u9762\u6765\u7ba1\u7406\u6570\u636e\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6570\u636e\u5e93\u8fde\u63a5\uff1a<\/strong><\/p>\n<p>PHP\u4ee3\u7801\u4e2d\u901a\u5e38\u4f1a\u6709\u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e\u6587\u4ef6\uff0c\u9700\u8981\u6839\u636e\u672c\u5730\u73af\u5883\u8bbe\u7f6e\u6b63\u786e\u7684\u6570\u636e\u5e93\u540d\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e<\/p>\n<p>\u786e\u4fddPHP\u6e90\u4ee3\u7801\u7684\u6587\u4ef6\u6709\u5408\u9002\u7684\u6743\u9650\uff0c\u4f7f\u5f97Web\u670d\u52a1\u5668\u80fd\u591f\u8bfb\u53d6\u5e76\u6267\u884c\u8fd9\u4e9b\u6587\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6587\u4ef6\u5939\u6743\u9650\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u5728Linux\u6216Mac\u7cfb\u7edf\u4e0a\uff0c\u53ef\u80fd\u9700\u8981\u8bbe\u7f6e\u6587\u4ef6\u5939\u7684\u6743\u9650\uff0c\u4ee5\u4fbf\u670d\u52a1\u5668\u80fd\u591f\u8bfb\u5199\u7279\u5b9a\u7684\u6587\u4ef6\u5939\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u5168\u8003\u91cf\uff1a<\/strong><\/p>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u6743\u9650\u65f6\uff0c\u540c\u65f6\u9700\u8981\u6ce8\u610f\u5b89\u5168\u6027\uff0c\u4e0d\u8981\u8bbe\u7f6e\u8fc7\u4e8e\u5bbd\u677e\u7684\u6743\u9650\uff0c\u7279\u522b\u662f\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u6d4b\u8bd5\u8fd0\u884c<\/p>\n<p>\u5b8c\u6210\u73af\u5883\u642d\u5efa\u3001\u670d\u52a1\u5668\u914d\u7f6e\u3001\u6570\u636e\u5e93\u914d\u7f6e\u548c\u6587\u4ef6\u6743\u9650\u8bbe\u7f6e\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u672c\u5730\u5f00\u59cb\u6d4b\u8bd5PHP\u6e90\u4ee3\u7801\u7684\u8fd0\u884c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9519\u8bef\u8c03\u8bd5\uff1a<\/strong><\/p>\n<p>\u5f00\u542fPHP\u7684\u9519\u8bef\u62a5\u544a\u529f\u80fd\uff0c\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u627e\u5230\u5e76\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002\u53ef\u4ee5\u7f16\u8f91<code>php.ini<\/code>\u6587\u4ef6\u6765\u5f00\u542f\u9519\u8bef\u62a5\u544a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u4e0e\u8c03\u8bd5\uff1a<\/strong><\/p>\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u4e4b\u524d\u8bbe\u7f6e\u7684\u670d\u52a1\u5668\u540d\uff0c\u67e5\u770b\u9879\u76ee\u662f\u5426\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u3002\u4f7f\u7528\u5f00\u53d1\u5de5\u5177\u8fdb\u884c\u4ee3\u7801\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5728\u672c\u5730\u642d\u5efa\u8d77\u4e00\u4e2aPHP\u7684\u5f00\u53d1\u4e0e\u6d4b\u8bd5\u73af\u5883\uff0c\u6709\u6548\u5730\u8fdb\u884c\u4ee3\u7801\u7684\u6d4b\u8bd5\u4e0e\u8c03\u8bd5\u3002\u8fd9\u5bf9\u4e8e\u4fdd\u969c\u4ee3\u7801\u7684\u8d28\u91cf\u3001\u4f18\u5316\u529f\u80fd\u4ee5\u53ca\u63d0\u524d\u9884\u9632\u6f5c\u5728\u7684\u90e8\u7f72\u95ee\u9898\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u95ee\u98981\uff1a\u5982\u4f55\u5728\u672c\u5730\u73af\u5883\u4e2d\u6d4b\u8bd5\u548c\u8fd0\u884c\u6574\u5957PHP\u6e90\u4ee3\u7801\uff1f<\/strong><\/p>\n<p>\u7b54\uff1a\u8981\u5728\u672c\u5730\u73af\u5883\u4e2d\u6d4b\u8bd5\u548c\u8fd0\u884c\u6574\u5957PHP\u6e90\u4ee3\u7801\uff0c\u60a8\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u5b89\u88c5\u672c\u5730\u5f00\u53d1\u73af\u5883<\/strong><br \/>\n\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e00\u4e2a\u672c\u5730\u5f00\u53d1\u73af\u5883\uff0c\u4f8b\u5982XAMPP\u3001WAMP\u6216MAMP\u7b49\u3002\u8fd9\u4e9b\u5f00\u53d1\u73af\u5883\u96c6\u6210\u4e86Apache\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\uff0c\u80fd\u591f\u6a21\u62df\u771f\u5b9e\u7684\u670d\u52a1\u5668\u73af\u5883\u3002<\/p>\n<p><strong>2. \u5c06\u6e90\u4ee3\u7801\u6587\u4ef6\u590d\u5236\u5230\u672c\u5730\u73af\u5883<\/strong><br \/>\n\u5c06\u6574\u5957PHP\u6e90\u4ee3\u7801\u590d\u5236\u5230\u60a8\u9009\u62e9\u7684\u672c\u5730\u5f00\u53d1\u73af\u5883\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\u3002\u901a\u5e38\uff0c\u8fd9\u4e2a\u76ee\u5f55\u5728XAMPP\u4e2d\u662f<code>htdocs<\/code>\uff0c\u5728WAMP\u4e2d\u662f<code>www<\/code>\uff0c\u5728MAMP\u4e2d\u662f<code>htdocs<\/code>\u3002<\/p>\n<p><strong>3. \u542f\u52a8\u672c\u5730\u5f00\u53d1\u73af\u5883<\/strong><br \/>\n\u542f\u52a8\u60a8\u9009\u62e9\u7684\u672c\u5730\u5f00\u53d1\u73af\u5883\u3002\u8fd9\u5c06\u542f\u52a8\u60a8\u7684\u672c\u5730\u670d\u52a1\u5668\u548c\u6570\u636e\u5e93\u670d\u52a1\u3002<\/p>\n<p><strong>4. \u521b\u5efa\u6570\u636e\u5e93<\/strong><br \/>\n\u5982\u679c\u6e90\u4ee3\u7801\u4f7f\u7528\u4e86\u6570\u636e\u5e93\uff0c\u60a8\u9700\u8981\u5728\u672c\u5730\u73af\u5883\u4e2d\u521b\u5efa\u4e00\u4e2a\u4e0e\u6e90\u4ee3\u7801\u76f8\u5bf9\u5e94\u7684\u6570\u636e\u5e93\uff0c\u5e76\u5c06\u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e\u66f4\u65b0\u4e3a\u672c\u5730\u73af\u5883\u7684\u6570\u636e\u5e93\u4fe1\u606f\u3002<\/p>\n<p><strong>5. \u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8bbf\u95ee<\/strong><br \/>\n\u6253\u5f00\u60a8\u7684\u6d4f\u89c8\u5668\uff0c\u8f93\u5165<code>http:\/\/localhost<\/code>\u6216<code>http:\/\/127.0.0.1<\/code>\uff0c\u52a0\u4e0a\u60a8\u7684\u6e90\u4ee3\u7801\u6240\u5728\u7684\u6587\u4ef6\u5939\u540d\u79f0\u6216\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6e90\u4ee3\u7801\u5728<code>htdocs\/myproject<\/code>\u6587\u4ef6\u5939\u4e2d\uff0c\u60a8\u5e94\u8be5\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165<code>http:\/\/localhost\/myproject<\/code>\u3002<\/p>\n<p><strong>6. \u8fd0\u884c\u6e90\u4ee3\u7801<\/strong><br \/>\n\u73b0\u5728\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u5728\u6d4f\u89c8\u5668\u4e2d\u770b\u5230\u60a8\u7684\u6e90\u4ee3\u7801\u7684\u8fd0\u884c\u7ed3\u679c\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u4e0e\u6e90\u4ee3\u7801\u8fdb\u884c\u4ea4\u4e92\u6765\u6d4b\u8bd5\u5176\u529f\u80fd\u3002<\/p>\n<p>\u5e0c\u671b\u4ee5\u4e0a\u6b65\u9aa4\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff0c\u5982\u679c\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u8bf7\u968f\u65f6\u63d0\u95ee\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"PHP\u662f\u4e00\u79cd\u88ab\u5e7f\u6cdb\u4f7f\u7528\u7684\u5f00\u653e\u6e90\u4ee3\u7801\u7684\u670d\u52a1\u5668\u7aef\u811a\u672c\u8bed\u8a00\uff0c\u672c\u5730\u6d4b\u8bd5\u8fd0\u884c\u6574\u5957PHP\u6e90\u4ee3\u7801\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a\u786e\u4fddP [&hellip;]","protected":false},"author":3,"featured_media":264557,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/264555"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=264555"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/264555\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/264557"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=264555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=264555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=264555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}