{"id":181558,"date":"2024-05-08T20:59:49","date_gmt":"2024-05-08T12:59:49","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/181558.html"},"modified":"2024-05-08T20:59:54","modified_gmt":"2024-05-08T12:59:54","slug":"mac%e4%b8%8b%e8%bf%98%e6%9c%89%e5%bf%85%e8%a6%81%e9%87%8d%e6%96%b0%e5%ae%89%e8%a3%85php%e5%90%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/181558.html","title":{"rendered":"Mac\u4e0b\u8fd8\u6709\u5fc5\u8981\u91cd\u65b0\u5b89\u88c5PHP\u5417"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27071227\/511c944f-86ce-4643-8336-1d0b909fb807.webp\" alt=\"Mac\u4e0b\u8fd8\u6709\u5fc5\u8981\u91cd\u65b0\u5b89\u88c5PHP\u5417\" \/><\/p>\n<p><p>Mac\u64cd\u4f5c\u7cfb\u7edf\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5df2\u7ecf\u9884\u88c5\u4e86PHP\u3002\u5bf9\u4e8e<strong>\u7cfb\u7edf\u81ea\u5e26\u7248\u672c\u662f\u5426\u8db3\u591f\u3001\u81ea\u5b9a\u4e49\u914d\u7f6e\u9700\u6c42<\/strong>\u4ee5\u53ca<strong>\u7248\u672c\u66f4\u65b0\u8ddf\u8e2a<\/strong>\u6765\u8bf4\uff0c\u4e86\u89e3\u662f\u5426\u9700\u8981\u91cd\u65b0\u5b89\u88c5PHP\u81f3\u5173\u91cd\u8981\u3002macOS\u7cfb\u7edf\u81ea\u5e26\u7684PHP\u7248\u672c\u5f80\u5f80\u4e0d\u662f\u6700\u65b0\u7248\u672c\uff0c\u800c\u4e14\u914d\u7f6e\u76f8\u5bf9\u56fa\u5b9a\uff0c\u5bf9\u4e8e\u5f00\u53d1\u4eba\u5458\u6765\u8bf4\uff0c\u53ef\u80fd\u65e0\u6cd5\u6ee1\u8db3\u67d0\u4e9b\u7279\u5b9a\u9879\u76ee\u7684\u9700\u6c42\u3002\u56e0\u6b64\uff0c\u82e5\u60a8\u9700\u8981\u7279\u5b9a\u7248\u672c\u7684PHP\u6216\u8005\u60f3\u8981\u66f4\u7075\u6d3b\u5730\u7ba1\u7406\u591a\u4e2aPHP\u7248\u672c\u53ca\u5176\u76f8\u5173\u914d\u7f6e\uff0c<strong>\u91cd\u65b0\u5b89\u88c5PHP\u662f\u4e00\u4e2a\u7406\u667a\u7684\u9009\u62e9<\/strong>\u3002\u4f7f\u7528\u5982Homebrew\u8fd9\u6837\u7684\u5305\u7ba1\u7406\u5668\u53ef\u4ee5\u6781\u5927\u5730\u7b80\u5316\u5b89\u88c5\u548c\u66f4\u65b0PHP\u7684\u8fc7\u7a0b\u3002\u6b64\u5916\uff0c\u91cd\u65b0\u5b89\u88c5\u8fd8\u610f\u5473\u7740\u60a8\u53ef\u4ee5\u83b7\u5f97PHP\u793e\u533a\u53d1\u5e03\u7684\u6700\u65b0\u5b89\u5168\u66f4\u65b0\u548c\u529f\u80fd\uff0c\u8fd9\u5bf9\u4e8e\u7ef4\u62a4\u73b0\u4ee3Web\u5e94\u7528\u6765\u8bf4\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981\u91cd\u65b0\u5b89\u88c5PHP<\/h3>\n<\/p>\n<p><h4>\u7cfb\u7edf\u7248\u672c\u53ef\u80fd\u8fc7\u65f6<\/h4>\n<\/p>\n<p><p>\u82e5\u9700\u8981\u4f7f\u7528PHP\u7684\u65b0\u7279\u6027\uff0c\u6216\u7cfb\u7edf\u81ea\u5e26\u7684PHP\u7248\u672c\u592a\u65e7\uff0c\u65e0\u6cd5\u6ee1\u8db3\u9879\u76ee\u8981\u6c42\uff0c\u5c31\u9700\u8981\u91cd\u65b0\u5b89\u88c5\u6765\u4fdd\u8bc1\u4f7f\u7528\u7684\u662f\u6700\u65b0\u7248PHP\u3002<\/p>\n<\/p>\n<p><h4>\u81ea\u5b9a\u4e49\u914d\u7f6e\u8981\u6c42<\/h4>\n<\/p>\n<p><p>\u9879\u76ee\u5f00\u53d1\u65f6\u53ef\u80fd\u9700\u8981\u4e0d\u540c\u7684PHP\u6269\u5c55\u6216\u8005\u7279\u5b9a\u7684\u73af\u5883\u914d\u7f6e\uff0c\u800c\u7cfb\u7edf\u81ea\u5e26\u7684PHP\u53ef\u80fd\u4e0d\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\u3002\u901a\u8fc7\u91cd\u65b0\u5b89\u88c5PHP\u53ef\u4ee5\u6309\u9700\u5b9a\u5236\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5982\u4f55\u91cd\u65b0\u5b89\u88c5PHP<\/h3>\n<\/p>\n<p><h4>\u9009\u62e9\u5408\u9002\u7684\u5b89\u88c5\u65b9\u5f0f<\/h4>\n<\/p>\n<p><p>\u5e38\u89c1\u7684PHP\u5b89\u88c5\u65b9\u5f0f\u5305\u62ec\u4f7f\u7528\u5305\u7ba1\u7406\u5668\uff08\u5982Homebrew\uff09\u6216\u662f\u76f4\u63a5\u4e0b\u8f7d\u6e90\u7801\u7f16\u8bd1\u5b89\u88c5\u3002<strong>\u4f7f\u7528Homebrew\u91cd\u65b0\u5b89\u88c5PHP<\/strong>\u901a\u5e38\u66f4\u52a0\u7b80\u5355\u5feb\u6377\u3002<\/p>\n<\/p>\n<p><h4>\u914d\u7f6e\u4e0e\u5b89\u88c5<\/h4>\n<\/p>\n<p><p>\u8fd0\u884c\u76f8\u5e94\u7684\u547d\u4ee4\u540e\uff0c\u5e94\u6b63\u786e\u914d\u7f6e\u5982php.ini\u7b49\u914d\u7f6e\u6587\u4ef6\u4ee5\u6ee1\u8db3\u5177\u4f53\u9700\u6c42\u3002\u5b89\u88c5\u540e\u9700\u786e\u4fdd\u7cfb\u7edf\u4f7f\u7528\u7684\u662f\u91cd\u65b0\u5b89\u88c5\u7684PHP\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/h3>\n<\/p>\n<p><h4>PHP\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/h4>\n<\/p>\n<p><p>\u5de5\u5177\u5982phpenv\u548cPHPBrew\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u540c\u4e00\u53f0\u673a\u5668\u4e0a\u5b89\u88c5\u548c\u7ba1\u7406\u591a\u4e2aPHP\u7248\u672c\u3002\u8fd9\u4e9b\u5de5\u5177\u7684\u4f7f\u7528\u53ef\u4ee5\u6781\u5927\u5730\u65b9\u4fbf\u5f00\u53d1\u8005\u9488\u5bf9\u4e0d\u540c\u9879\u76ee\u5207\u6362PHP\u73af\u5883\u3002<\/p>\n<\/p>\n<p><h4>\u7248\u672c\u5207\u6362<\/h4>\n<\/p>\n<p><p>\u8fd9\u4e9b\u7248\u672c\u7ba1\u7406\u5de5\u5177\u901a\u5e38\u63d0\u4f9b\u4e00\u7cfb\u5217\u547d\u4ee4\uff0c\u4ee5\u4fbf\u4e8e\u7528\u6237\u5207\u6362\u5f53\u524d\u4f7f\u7528\u7684PHP\u7248\u672c\u3002\u4e86\u89e3\u5982\u4f55\u6b63\u786e\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\uff0c\u4ee5\u786e\u4fdd\u5728\u4e0d\u540c\u9879\u76ee\u95f4\u5207\u6362\u65f6\u80fd\u591f\u9ad8\u6548\u5730\u8fdb\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u5b89\u88c5PHP\u6269\u5c55<\/h3>\n<\/p>\n<p><h4>\u4f7f\u7528\u5305\u7ba1\u7406\u5668\u5b89\u88c5\u6269\u5c55<\/h4>\n<\/p>\n<p><p>\u5927\u591a\u6570\u6d41\u884c\u7684PHP\u6269\u5c55\u53ef\u4ee5\u901a\u8fc7\u5305\u7ba1\u7406\u5668\u76f4\u63a5\u5b89\u88c5\uff0c\u8fd9\u6837\u505a\u964d\u4f4e\u4e86\u590d\u6742\u6027\u5e76\u8282\u7701\u4e86\u65f6\u95f4\u3002\u786e\u5b9a\u6240\u9700\u6269\u5c55\uff0c\u5e76\u901a\u8fc7\u76f8\u5e94\u7684\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><h4>\u624b\u52a8\u7f16\u8bd1\u6269\u5c55<\/h4>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u624b\u52a8\u7f16\u8bd1\u5b89\u88c5\u6269\u5c55\uff0c\u8fd9\u901a\u5e38\u6d89\u53ca\u4e0b\u8f7d\u6269\u5c55\u6e90\u7801\u3001\u7f16\u8bd1\u5e76\u914d\u7f6e\u5230PHP\u4e2d\u3002\u4e86\u89e3\u57fa\u672c\u7684\u7f16\u8bd1\u547d\u4ee4\u548c\u914d\u7f6e\u9009\u9879\u662f\u5fc5\u8981\u7684\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u914d\u7f6eWeb\u670d\u52a1\u5668\u4e0ePHP<\/h3>\n<\/p>\n<p><h4>Web\u670d\u52a1\u5668\u9009\u62e9<\/h4>\n<\/p>\n<p><p>\u6839\u636e\u5f00\u53d1\u7684\u9879\u76ee\u9700\u6c42\uff0c\u9009\u62e9\u5408\u9002\u7684Web\u670d\u52a1\u5668\uff0c\u5982Nginx\u6216Apache\u3002<strong>\u4e0ePHP\u6574\u5408<\/strong>\u662f\u4f7f\u5f97Web\u5e94\u7528\u80fd\u591f\u8fd0\u884c\u7684\u5173\u952e\u73af\u8282\u3002<\/p>\n<\/p>\n<p><h4>\u914d\u7f6e\u8fc7\u7a0b<\/h4>\n<\/p>\n<p><p>\u914d\u7f6e\u8fc7\u7a0b\u901a\u5e38\u6d89\u53ca\u7f16\u8f91\u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6\uff0c\u4ee5\u6307\u5b9aPHP\u5904\u7406\u7a0b\u5e8f\u7684\u4fe1\u606f\u3002\u8fd9\u91cc\u9700\u8981\u5177\u4f53\u4e86\u89e3\u4e00\u4e9b\u670d\u52a1\u914d\u7f6e\u7684\u8bed\u6cd5\u548c\u53c2\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u73af\u5883\u6d4b\u8bd5\u4e0e\u95ee\u9898\u6392\u67e5<\/h3>\n<\/p>\n<p><h4>\u8fd0\u884cPHP\u6d4b\u8bd5\u811a\u672c<\/h4>\n<\/p>\n<p><p>\u5b89\u88c5\u6216\u66f4\u65b0PHP\u7248\u672c\u540e\uff0c\u901a\u8fc7\u7f16\u5199\u7b80\u5355\u7684PHP\u811a\u672c\u6d4b\u8bd5PHP\u73af\u5883\uff0c\u786e\u4fddPHP\u8fd0\u884c\u6b63\u5e38\u3002<\/p>\n<\/p>\n<p><h4>\u6392\u67e5\u5e38\u89c1\u5b89\u88c5\u95ee\u9898<\/h4>\n<\/p>\n<p><p>\u5728\u6574\u4e2a\u91cd\u65b0\u5b89\u88c5\u7684\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u7cfb\u5217\u95ee\u9898\uff0c\u6bd4\u5982\u8def\u5f84\u8bbe\u7f6e\u4e0d\u6b63\u786e\u3001\u6743\u9650\u95ee\u9898\u7b49\u3002\u719f\u7ec3\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u7684\u6392\u9519\u6280\u5de7\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<\/p>\n<p><h3>\u4e03\u3001\u7ef4\u62a4\u4e0e\u66f4\u65b0<\/h3>\n<\/p>\n<p><h4>\u5b9a\u671f\u66f4\u65b0<\/h4>\n<\/p>\n<p><p>\u4fdd\u6301PHP\u7248\u672c\u7684\u66f4\u65b0\uff0c\u4ee5\u83b7\u5f97\u6700\u65b0\u7684\u5b89\u5168\u4fee\u590d\u548c\u529f\u80fd\u589e\u5f3a\u3002\u5b9a\u671f\u8fd0\u884c\u66f4\u65b0\u547d\u4ee4\u6765\u7ba1\u7406PHP\u7248\u672c\u3002<\/p>\n<\/p>\n<p><h4>\u5b89\u5168\u6027\u548c\u6027\u80fd\u8003\u8651<\/h4>\n<\/p>\n<p><p>\u6b63\u786e\u914d\u7f6ePHP\u8bbe\u7f6e\uff0c\u4f8b\u5982\u7981\u7528\u672a\u4f7f\u7528\u7684\u6269\u5c55\uff0c\u53ef\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u548c\u6027\u80fd\u8868\u73b0\u3002\u65f6\u523b\u5173\u6ce8PHP\u7684\u5b89\u5168\u516c\u544a\u548c\u6027\u80fd\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>\u91cd\u65b0\u5b89\u88c5PHP\u5bf9\u4e8e\u90a3\u4e9b\u9700\u8981\u6700\u65b0\u7279\u6027\u3001\u5b9a\u5236\u914d\u7f6e\u6216\u5904\u7406\u591a\u4e2a\u9879\u76ee\u9700\u6c42\u7684\u5f00\u53d1\u4eba\u5458\u6765\u8bf4\u662f\u975e\u5e38\u6709\u7528\u7684\u3002\u5229\u7528\u5305\u7ba1\u7406\u5668\u53ef\u4ee5\u7b80\u5316\u8fc7\u7a0b\uff0c\u5e76\u901a\u8fc7\u7248\u672c\u7ba1\u7406\u5de5\u5177\u5b9e\u73b0\u66f4\u9ad8\u6548\u7684\u7248\u672c\u63a7\u5236\u3002\u786e\u4fdd\u5728\u91cd\u65b0\u5b89\u88c5\u6216\u5347\u7ea7PHP\u4e4b\u540e\uff0c\u59a5\u5584\u5730\u8fdb\u884c\u914d\u7f6e\u548c\u6d4b\u8bd5\uff0c\u4ee5\u4fdd\u6301\u9ad8\u6548\u3001\u5b89\u5168\u7684\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. Mac\u4e0b\u5982\u4f55\u5b89\u88c5PHP\uff1f<\/strong><br \/>\n\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fMac\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u4e14\u60f3\u8981\u5b89\u88c5PHP\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li>\u4f7f\u7528Homebrew\u5305\u7ba1\u7406\u5668\u8fdb\u884c\u5b89\u88c5\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>brew install php<\/code><\/li>\n<li>\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528<code>php -v<\/code>\u547d\u4ee4\u68c0\u67e5\u5b89\u88c5\u7ed3\u679c\uff0c\u663e\u793a\u51faPHP\u7684\u7248\u672c\u4fe1\u606f\u5373\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ul>\n<p><strong>2. \u4e3a\u4ec0\u4e48\u6211\u9700\u8981\u91cd\u65b0\u5b89\u88c5PHP\uff1f<\/strong><br \/>\n\u6709\u51e0\u79cd\u60c5\u51b5\u4e0b\u60a8\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u5b89\u88c5PHP\uff1a<\/p>\n<ul>\n<li>\u60a8\u5e0c\u671b\u5347\u7ea7\u5230\u65b0\u7248\u672c\u7684PHP\u3002\u65b0\u7248\u672c\u901a\u5e38\u4f1a\u5f15\u5165\u65b0\u7684\u529f\u80fd\u3001\u4fee\u590d\u6f0f\u6d1e\u5e76\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li>\u60a8\u5728\u5b89\u88c5PHP\u65f6\u9047\u5230\u4e86\u4e00\u4e9b\u95ee\u9898\uff0c\u5bfc\u81f4PHP\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002\u91cd\u65b0\u5b89\u88c5\u53ef\u80fd\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u3002<\/li>\n<li>\u60a8\u60f3\u8981\u5b89\u88c5PHP\u7684\u7279\u5b9a\u6269\u5c55\u6216\u6a21\u5757\uff0c\u4f46\u5728\u4e4b\u524d\u7684\u5b89\u88c5\u4e2d\u6ca1\u6709\u9009\u62e9\u5b83\u4eec\u3002<\/li>\n<\/ul>\n<p><strong>3. \u662f\u5426\u5fc5\u987b\u5728Mac\u4e0a\u91cd\u65b0\u5b89\u88c5PHP\uff1f<\/strong><br \/>\n\u91cd\u65b0\u5b89\u88c5PHP\u5e76\u4e0d\u662f\u5fc5\u987b\u7684\u3002\u5982\u679c\u60a8\u5f53\u524d\u7684PHP\u7248\u672c\u80fd\u591f\u6ee1\u8db3\u60a8\u7684\u9700\u6c42\uff0c\u5e76\u4e14\u6ca1\u6709\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u90a3\u4e48\u60a8\u53ef\u4ee5\u7ee7\u7eed\u4f7f\u7528\u73b0\u6709\u7684\u5b89\u88c5\u3002\u53ea\u6709\u5728\u60a8\u9700\u8981\u5347\u7ea7\u3001\u4fee\u590d\u95ee\u9898\u6216\u5b89\u88c5\u7279\u5b9a\u6269\u5c55\u65f6\uff0c\u624d\u9700\u8981\u8003\u8651\u91cd\u65b0\u5b89\u88c5PHP\u3002\u786e\u4fdd\u5728\u5b89\u88c5\u6216\u5347\u7ea7\u4e4b\u524d\u5907\u4efd\u91cd\u8981\u7684\u6587\u4ef6\u548c\u914d\u7f6e\uff0c\u5e76\u505a\u597d\u76f8\u5173\u6d4b\u8bd5\u4ee5\u786e\u4fdd\u4e00\u5207\u6b63\u5e38\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Mac\u64cd\u4f5c\u7cfb\u7edf\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5df2\u7ecf\u9884\u88c5\u4e86PHP\u3002\u5bf9\u4e8e\u7cfb\u7edf\u81ea\u5e26\u7248\u672c\u662f\u5426\u8db3\u591f\u3001\u81ea\u5b9a\u4e49\u914d\u7f6e\u9700\u6c42\u4ee5\u53ca\u7248\u672c\u66f4\u65b0\u8ddf\u8e2a\u6765\u8bf4\uff0c\u4e86\u89e3\u662f [&hellip;]","protected":false},"author":3,"featured_media":181562,"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\/181558"}],"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=181558"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/181558\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/181562"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=181558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=181558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=181558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}