{"id":61747,"date":"2024-10-13T13:20:15","date_gmt":"2024-10-13T05:20:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/61747\/"},"modified":"2024-10-13T13:20:15","modified_gmt":"2024-10-13T05:20:15","slug":"iis%e8%88%87php%e6%90%ad%e9%85%8d%ef%bc%8c%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-iis-php%e9%85%8d%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/61747\/","title":{"rendered":"IIS\u8207PHP\u642d\u914d\uff0c\u5982\u4f55\u914d\u7f6e\u6578\u64da\u5eab\uff1f (iis php\u914d\u7f6e\u6578\u64da\u5eab)"},"content":{"rendered":"<h1 id=\"iis%e8%88%87php%e6%90%ad%e9%85%8d%ef%bc%8c%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e6%95%b8%e6%93%9a%e5%ba%ab%ef%bc%9f-HgkMZUvYyg\">IIS\u8207PHP\u642d\u914d\uff0c\u5982\u4f55\u914d\u7f6e\u6578\u64da\u5eab\uff1f<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cIIS\uff08Internet Information Services\uff09\u548cPHP\u7684\u7d50\u5408\u8d8a\u4f86\u8d8a\u53d7\u5230\u958b\u767c\u8005\u7684\u9752\u775e\u3002\u9019\u7a2e\u7d44\u5408\u4e0d\u50c5\u80fd\u5920\u63d0\u4f9b\u7a69\u5b9a\u7684\u7db2\u7ad9\u904b\u884c\u74b0\u5883\uff0c\u9084\u80fd\u5920\u5229\u7528PHP\u7684\u9748\u6d3b\u6027\u4f86\u958b\u767c\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5728IIS\u4e0a\u914d\u7f6ePHP\u4e26\u9023\u63a5\u6578\u64da\u5eab\uff0c\u7279\u5225\u662f\u4f7f\u7528MySQL\u4f5c\u70ba\u6578\u64da\u5eab\u7684\u60c5\u6cc1\u3002<\/p>\n<h2 id=\"1-%e5%ae%89%e8%a3%9diis%e5%92%8cphp-HgkMZUvYyg\">1. \u5b89\u88ddIIS\u548cPHP<\/h2>\n<p>\u9996\u5148\uff0c\u78ba\u4fdd\u4f60\u7684Windows\u7cfb\u7d71\u4e0a\u5df2\u7d93\u5b89\u88dd\u4e86IIS\u3002\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u6b65\u9a5f\u4f86\u5b89\u88ddIIS\uff1a<\/p>\n<ul>\n<li>\u6253\u958b\u63a7\u5236\u9762\u677f\uff0c\u9078\u64c7\u201c\u7a0b\u5e8f\u201d\u9078\u9805\u3002<\/li>\n<li>\u9ede\u64ca\u201c\u555f\u7528\u6216\u95dc\u9589Windows\u529f\u80fd\u201d\u3002<\/li>\n<li>\u5728\u5f48\u51fa\u7684\u7a97\u53e3\u4e2d\uff0c\u52fe\u9078\u201cIIS\u201d\u53ca\u5176\u76f8\u95dc\u529f\u80fd\uff0c\u7136\u5f8c\u9ede\u64ca\u201c\u78ba\u5b9a\u201d\u3002<\/li>\n<\/ul>\n<p>\u5b89\u88dd\u5b8cIIS\u5f8c\uff0c\u63a5\u4e0b\u4f86\u9700\u8981\u5b89\u88ddPHP\u3002\u53ef\u4ee5\u5f9ePHP\u7684\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u7684PHP\uff0c\u4e26\u89e3\u58d3\u5230\u4e00\u500b\u5408\u9069\u7684\u76ee\u9304\uff0c\u4f8b\u5982C:PHP\u3002<\/p>\n<h2 id=\"2-%e9%85%8d%e7%bd%aeiis%e4%bb%a5%e6%94%af%e6%8c%81php-HgkMZUvYyg\">2. \u914d\u7f6eIIS\u4ee5\u652f\u6301PHP<\/h2>\n<p>\u5728IIS\u4e2d\u914d\u7f6ePHP\u9700\u8981\u9032\u884c\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<ul>\n<li>\u6253\u958bIIS\u7ba1\u7406\u5668\uff0c\u53f3\u9375\u9ede\u64ca\u4f60\u7684\u7db2\u7ad9\uff0c\u9078\u64c7\u201c\u6dfb\u52a0\u61c9\u7528\u7a0b\u5e8f\u201d\u4f86\u8a2d\u7f6ePHP\u61c9\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u9304\u3002<\/li>\n<li>\u5728\u201c\u8655\u7406\u7a0b\u5e8f\u6620\u5c04\u201d\u4e2d\u6dfb\u52a0PHP\u7684\u8655\u7406\u7a0b\u5e8f\u3002\u9ede\u64ca\u201c\u8655\u7406\u7a0b\u5e8f\u6620\u5c04\u201d\uff0c\u7136\u5f8c\u9078\u64c7\u201c\u6dfb\u52a0\u6a21\u584a\u6620\u5c04\u201d\u3002<\/li>\n<li>\u5728\u201c\u8acb\u6c42\u8def\u5f91\u201d\u4e2d\u8f38\u5165\u201c*.php\u201d\uff0c\u5728\u201c\u6a21\u584a\u201d\u4e2d\u9078\u64c7\u201cFastCgiModule\u201d\uff0c\u5728\u201c\u53ef\u57f7\u884c\u6587\u4ef6\u201d\u4e2d\u9078\u64c7PHP\u7684\u57f7\u884c\u6587\u4ef6\uff08\u4f8b\u5982C:PHPphp-cgi.exe\uff09\uff0c\u4e26\u7d66\u5b83\u4e00\u500b\u540d\u7a31\u3002<\/li>\n<\/ul>\n<p>\u5b8c\u6210\u9019\u4e9b\u6b65\u9a5f\u5f8c\uff0cIIS\u5c31\u80fd\u5920\u8655\u7406PHP\u6587\u4ef6\u4e86\u3002<\/p>\n<h2 id=\"3-%e5%ae%89%e8%a3%9dmysql%e6%95%b8%e6%93%9a%e5%ba%ab-HgkMZUvYyg\">3. \u5b89\u88ddMySQL\u6578\u64da\u5eab<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88ddMySQL\u6578\u64da\u5eab\u3002\u53ef\u4ee5\u5f9eMySQL\u7684\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u5b89\u88dd\u5305\uff0c\u4e26\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88dd\u3002\u5728\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u8a18\u5f97\u8a2d\u7f6e\u597d\u6578\u64da\u5eab\u7684\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002<\/p>\n<h2 id=\"4-%e9%85%8d%e7%bd%aephp%e4%bb%a5%e9%80%a3%e6%8e%a5mysql-HgkMZUvYyg\">4. \u914d\u7f6ePHP\u4ee5\u9023\u63a5MySQL<\/h2>\n<p>\u5728PHP\u4e2d\u9023\u63a5MySQL\u6578\u64da\u5eab\u9700\u8981\u4f7f\u7528PDO\u6216MySQLi\u64f4\u5c55\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528MySQLi\u7684\u57fa\u672c\u793a\u4f8b\uff1a<\/p>\n<pre><code>&lt;?php\n$servername = \"localhost\";\n$username = \"your_username\";\n$password = \"your_password\";\n$dbname = \"your_database\";\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?&gt;<\/code><\/pre>\n<p>\u5728\u9019\u6bb5\u4ee3\u78bc\u4e2d\uff0c\u8acb\u5c07\u201cyour_username\u201d\u3001\u201cyour_password\u201d\u548c\u201cyour_database\u201d\u66ff\u63db\u70ba\u4f60\u5be6\u969b\u7684\u6578\u64da\u5eab\u7528\u6236\u540d\u3001\u5bc6\u78bc\u548c\u6578\u64da\u5eab\u540d\u7a31\u3002<\/p>\n<h2 id=\"5-%e6%b8%ac%e8%a9%a6%e9%80%a3%e6%8e%a5-HgkMZUvYyg\">5. \u6e2c\u8a66\u9023\u63a5<\/h2>\n<p>\u5c07\u4e0a\u8ff0\u4ee3\u78bc\u4fdd\u5b58\u70batest.php\uff0c\u7136\u5f8c\u5c07\u5176\u653e\u7f6e\u5728IIS\u7684\u7db2\u7ad9\u6839\u76ee\u9304\u4e2d\u3002\u901a\u904e\u700f\u89bd\u5668\u8a2a\u554fhttp:\/\/localhost\/test.php\uff0c\u82e5\u986f\u793a\u201c\u9023\u63a5\u6210\u529f\u201d\uff0c\u5247\u8868\u793a\u914d\u7f6e\u6210\u529f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-HgkMZUvYyg\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u6211\u5011\u53ef\u4ee5\u5728IIS\u4e0a\u6210\u529f\u914d\u7f6ePHP\u4e26\u9023\u63a5MySQL\u6578\u64da\u5eab\u3002\u9019\u7a2e\u7d44\u5408\u4e0d\u50c5\u80fd\u5920\u63d0\u4f9b\u7a69\u5b9a\u7684\u7db2\u7ad9\u904b\u884c\u74b0\u5883\uff0c\u9084\u80fd\u5920\u5229\u7528PHP\u7684\u9748\u6d3b\u6027\u4f86\u958b\u767c\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u4e0d\u540c\u9700\u6c42\u7684\u7528\u6236\u3002\u7121\u8ad6\u662f\u642d\u5efa\u7db2\u7ad9\u9084\u662f\u958b\u767c\u61c9\u7528\uff0c\u9078\u64c7\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">\u4f3a\u670d\u5668<\/a> \u90fd\u662f\u6210\u529f\u7684\u95dc\u9375\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728IIS\u4e0a\u914d\u7f6ePHP\u8207\u6578\u64da\u5eab\u7684\u642d\u914d\uff0c\u6b65\u9a5f\u7c21\u55ae\uff0c\u52a9\u4f60\u5feb\u901f\u5efa\u7acb\u7a69\u5b9a\u7684\u7db2\u9801\u61c9\u7528\u74b0\u5883\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-61747","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61747","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=61747"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61747\/revisions"}],"predecessor-version":[{"id":61748,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61747\/revisions\/61748"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=61747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=61747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=61747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}