{"id":48762,"date":"2024-10-08T00:01:44","date_gmt":"2024-10-07T16:01:44","guid":{"rendered":"https:\/\/server.hk\/cnblog\/48762\/"},"modified":"2024-10-08T00:01:44","modified_gmt":"2024-10-07T16:01:44","slug":"windows-2016-iis-10-0-php-mysql-%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/48762\/","title":{"rendered":"Windows 2016 IIS 10.0 + PHP + MySQL \u74b0\u5883\u642d\u5efa"},"content":{"rendered":"<h1 id=\"windows-2016-iis-10-0-php-mysql-%e7%92%b0%e5%a2%83%e6%90%ad%e5%bb%ba-khjFKJDtqg\">Windows 2016 IIS 10.0 + PHP + MySQL \u74b0\u5883\u642d\u5efa<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u642d\u5efa\u4e00\u500b\u7a69\u5b9a\u4e14\u9ad8\u6548\u7684\u4f3a\u670d\u5668\u74b0\u5883\u662f\u6bcf\u500b\u958b\u767c\u8005\u548c\u4f01\u696d\u7684\u57fa\u672c\u9700\u6c42\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 Windows Server 2016 \u4e0a\u642d\u5efa IIS 10.0\u3001PHP \u548c MySQL \u7684\u74b0\u5883\uff0c\u8b93\u60a8\u80fd\u5920\u8f15\u9b06\u5730\u90e8\u7f72\u548c\u7ba1\u7406\u60a8\u7684\u7db2\u7ad9\u6216\u61c9\u7528\u7a0b\u5f0f\u3002<\/p>\n<h2 id=\"%e4%b8%80%e3%80%81%e5%ae%89%e8%a3%9d-iis-10-0-khjFKJDtqg\">\u4e00\u3001\u5b89\u88dd IIS 10.0<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728 Windows Server 2016 \u4e0a\u5b89\u88dd Internet Information Services (IIS)\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u6253\u958b\u300c\u4f3a\u670d\u5668\u7ba1\u7406\u54e1\u300d\uff0c\u9078\u64c7\u300c\u7ba1\u7406\u300d&gt;\u300c\u6dfb\u52a0\u89d2\u8272\u548c\u529f\u80fd\u300d\u3002<\/li>\n<li>\u5728\u300c\u89d2\u8272\u300d\u9078\u64c7\u9801\u9762\u4e2d\uff0c\u52fe\u9078\u300cWeb \u4f3a\u670d\u5668 (IIS)\u300d\u3002<\/li>\n<li>\u6839\u64da\u63d0\u793a\u5b8c\u6210\u5b89\u88dd\uff0c\u4e26\u78ba\u4fdd\u9078\u64c7\u4e86\u5fc5\u8981\u7684\u529f\u80fd\uff0c\u4f8b\u5982\u300cASP.NET\u300d\u548c\u300cCGI\u300d\u3002<\/li>\n<\/ol>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165 <code>http:\/\/localhost<\/code> \u4f86\u6aa2\u67e5 IIS \u662f\u5426\u6b63\u5e38\u904b\u884c\u3002<\/p>\n<h2 id=\"%e4%ba%8c%e3%80%81%e5%ae%89%e8%a3%9d-php-khjFKJDtqg\">\u4e8c\u3001\u5b89\u88dd PHP<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd PHP\u3002\u53ef\u4ee5\u5f9e PHP \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684 PHP\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u4e0b\u8f09 PHP \u7684 Windows \u7248\u672c\uff0c\u89e3\u58d3\u7e2e\u5230\u4e00\u500b\u76ee\u9304\uff0c\u4f8b\u5982 <code>C:PHP<\/code>\u3002<\/li>\n<li>\u5728 IIS \u4e2d\uff0c\u60a8\u9700\u8981\u914d\u7f6e PHP \u7684 FastCGI\u3002\u6253\u958b\u300cIIS \u7ba1\u7406\u5668\u300d\uff0c\u9078\u64c7\u60a8\u7684\u4f3a\u670d\u5668\uff0c\u7136\u5f8c\u5728\u53f3\u5074\u7684\u300c\u529f\u80fd\u8996\u5716\u300d\u4e2d\u627e\u5230\u300c\u8655\u7406\u7a0b\u5e8f\u6620\u5c04\u300d\u3002<\/li>\n<li>\u6dfb\u52a0\u65b0\u7684 FastCGI \u61c9\u7528\u7a0b\u5f0f\uff0c\u6307\u5411 PHP \u7684\u57f7\u884c\u6a94\uff0c\u4f8b\u5982 <code>C:PHPphp-cgi.exe<\/code>\u3002<\/li>\n<li>\u5728\u300cPHP \u8a2d\u5b9a\u300d\u4e2d\uff0c\u60a8\u53ef\u4ee5\u8a2d\u7f6e PHP \u7684\u914d\u7f6e\u6a94\u6848 <code>php.ini<\/code>\uff0c\u78ba\u4fdd\u555f\u7528\u5fc5\u8981\u7684\u64f4\u5c55\uff0c\u4f8b\u5982 <code>extension=mysqli<\/code>\u3002<\/li>\n<\/ol>\n<h2 id=\"%e4%b8%89%e3%80%81%e5%ae%89%e8%a3%9d-mysql-khjFKJDtqg\">\u4e09\u3001\u5b89\u88dd MySQL<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5b89\u88dd MySQL \u6578\u64da\u5eab\u3002\u53ef\u4ee5\u5f9e MySQL \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u5b89\u88dd\u5305\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u4e0b\u8f09 MySQL \u5b89\u88dd\u5305\uff0c\u4e26\u904b\u884c\u5b89\u88dd\u7a0b\u5f0f\u3002<\/li>\n<li>\u5728\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u9078\u64c7\u300c\u958b\u767c\u8005\u9ed8\u8a8d\u300d\u5b89\u88dd\u985e\u578b\uff0c\u9019\u6a23\u6703\u5b89\u88dd MySQL Server \u548c MySQL Workbench\u3002<\/li>\n<li>\u8a2d\u7f6e root \u7528\u6236\u7684\u5bc6\u78bc\uff0c\u4e26\u8a18\u4e0b\u9019\u500b\u5bc6\u78bc\u4ee5\u4fbf\u5f8c\u7e8c\u4f7f\u7528\u3002<\/li>\n<li>\u5b8c\u6210\u5b89\u88dd\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 MySQL Workbench \u4f86\u7ba1\u7406\u6578\u64da\u5eab\u3002<\/li>\n<\/ol>\n<h2 id=\"%e5%9b%9b%e3%80%81%e6%b8%ac%e8%a9%a6%e7%92%b0%e5%a2%83-khjFKJDtqg\">\u56db\u3001\u6e2c\u8a66\u74b0\u5883<\/h2>\n<p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9a5f\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684 PHP \u6e2c\u8a66\u6a94\u6848\u4f86\u6aa2\u67e5 PHP \u548c MySQL \u662f\u5426\u6b63\u5e38\u904b\u884c\u3002\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>info.php<\/code> \u7684\u6a94\u6848\uff0c\u5167\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>&lt;?php\nphpinfo();\n?&gt;<\/code><\/pre>\n<p>\u5c07\u6b64\u6a94\u6848\u653e\u7f6e\u65bc IIS \u7684\u6839\u76ee\u9304\uff08\u901a\u5e38\u662f <code>C:inetpubwwwroot<\/code>\uff09\uff0c\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165 <code>http:\/\/localhost\/info.php<\/code>\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u5c07\u770b\u5230 PHP \u7684\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e4%ba%94%e3%80%81%e9%80%a3%e6%8e%a5-mysql-%e6%95%b8%e6%93%9a%e5%ba%ab-khjFKJDtqg\">\u4e94\u3001\u9023\u63a5 MySQL \u6578\u64da\u5eab<\/h2>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b PHP \u4ee3\u78bc\u4f86\u6e2c\u8a66\u8207 MySQL \u6578\u64da\u5eab\u7684\u9023\u63a5\uff1a<\/p>\n<pre><code>&lt;?php\n$servername = \"localhost\";\n$username = \"root\";\n$password = \"\u60a8\u7684\u5bc6\u78bc\";\n$dbname = \"test_db\";\n\n\/\/ \u5275\u5efa\u9023\u63a5\n$conn = new mysqli($servername, $username, $password, $dbname);\n\n\/\/ \u6aa2\u67e5\u9023\u63a5\nif ($conn-&gt;connect_error) {\n    die(\"\u9023\u63a5\u5931\u6557: \" . $conn-&gt;connect_error);\n}\necho \"\u9023\u63a5\u6210\u529f\";\n$conn-&gt;close();\n?&gt;<\/code><\/pre>\n<p>\u5c07\u6b64\u4ee3\u78bc\u653e\u5165\u4e00\u500b\u65b0\u7684 PHP \u6a94\u6848\u4e2d\uff0c\u4e26\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230\u300c\u9023\u63a5\u6210\u529f\u300d\u7684\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-khjFKJDtqg\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u5df2\u7d93\u6210\u529f\u5728 Windows Server 2016 \u4e0a\u642d\u5efa\u4e86 IIS 10.0\u3001PHP \u548c MySQL \u7684\u74b0\u5883\u3002\u9019\u6a23\u7684\u74b0\u5883\u4e0d\u50c5\u9069\u5408\u958b\u767c\u548c\u6e2c\u8a66\uff0c\u9084\u80fd\u5920\u652f\u6301\u751f\u7522\u74b0\u5883\u7684\u9700\u6c42\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\u61c9\u7528\u63d0\u4f9b\u66f4\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to set up a Windows 2016 server with IIS 10.0, PHP, and MySQL for a robust web development environment. Step-by-step guide included.<\/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-48762","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/48762","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=48762"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/48762\/revisions"}],"predecessor-version":[{"id":48763,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/48762\/revisions\/48763"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=48762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=48762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=48762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}