{"id":49396,"date":"2024-10-08T04:26:27","date_gmt":"2024-10-07T20:26:27","guid":{"rendered":"https:\/\/server.hk\/cnblog\/49396\/"},"modified":"2024-10-08T04:26:27","modified_gmt":"2024-10-07T20:26:27","slug":"%e8%ae%93-iis-7-5-%e5%9f%b7%e8%a1%8c-python-%e8%85%b3%e6%9c%ac%e7%9a%84%e9%85%8d%e7%bd%ae%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/49396\/","title":{"rendered":"\u8b93 IIS 7.5 \u57f7\u884c Python \u8173\u672c\u7684\u914d\u7f6e\u65b9\u6cd5"},"content":{"rendered":"<h1 id=\"%e8%ae%93-iis-7-5-%e5%9f%b7%e8%a1%8c-python-%e8%85%b3%e6%9c%ac%e7%9a%84%e9%85%8d%e7%bd%ae%e6%96%b9%e6%b3%95-KcLMGohVxY\">\u8b93 IIS 7.5 \u57f7\u884c Python \u8173\u672c\u7684\u914d\u7f6e\u65b9\u6cd5<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cPython \u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u4e14\u6613\u65bc\u5b78\u7fd2\u7684\u7de8\u7a0b\u8a9e\u8a00\uff0c\u8d8a\u4f86\u8d8a\u53d7\u5230\u958b\u767c\u8005\u7684\u9752\u775e\u3002\u96d6\u7136 IIS\uff08Internet Information Services\uff09\u4e3b\u8981\u7528\u65bc\u904b\u884c ASP.NET \u61c9\u7528\u7a0b\u5e8f\uff0c\u4f46\u901a\u904e\u9069\u7576\u7684\u914d\u7f6e\uff0cIIS 7.5 \u4e5f\u80fd\u5920\u57f7\u884c Python \u8173\u672c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 IIS 7.5 \u4e0a\u914d\u7f6e Python \u74b0\u5883\uff0c\u4ee5\u4fbf\u80fd\u5920\u904b\u884c Python \u8173\u672c\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-KcLMGohVxY\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u914d\u7f6e\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u5df2\u5b89\u88dd IIS 7.5\u3002<\/li>\n<li>\u5df2\u5b89\u88dd Python\uff08\u5efa\u8b70\u4f7f\u7528 Python 2.7 \u6216 3.x \u7248\u672c\uff09\u3002<\/li>\n<li>\u64c1\u6709\u7ba1\u7406\u54e1\u6b0a\u9650\u4ee5\u9032\u884c\u5fc5\u8981\u7684\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%ae%89%e8%a3%9d%e5%92%8c%e9%85%8d%e7%bd%ae-python-KcLMGohVxY\">\u5b89\u88dd\u548c\u914d\u7f6e Python<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728\u4f3a\u670d\u5668\u4e0a\u5b89\u88dd Python\u3002\u53ef\u4ee5\u5f9e\u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09\u9069\u5408\u60a8\u7cfb\u7d71\u7684\u5b89\u88dd\u5305\uff0c\u4e26\u6309\u7167\u63d0\u793a\u5b8c\u6210\u5b89\u88dd\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u547d\u4ee4\u63d0\u793a\u7b26\u6aa2\u67e5 Python \u662f\u5426\u5b89\u88dd\u6210\u529f\uff1a<\/p>\n<pre><code>python --version<\/code><\/pre>\n<p>\u5982\u679c\u986f\u793a\u51fa Python \u7684\u7248\u672c\u865f\uff0c\u5247\u8868\u793a\u5b89\u88dd\u6210\u529f\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%ae-iis-%e4%bb%a5%e6%94%af%e6%8c%81-python-KcLMGohVxY\">\u914d\u7f6e IIS \u4ee5\u652f\u6301 Python<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5728 IIS \u4e2d\u914d\u7f6e Python \u7684\u652f\u6301\u3002\u9019\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u6b65\u9a5f\u5b8c\u6210\uff1a<\/p>\n<h3 id=\"1-%e5%ae%89%e8%a3%9d-isapi-%e6%93%b4%e5%b1%95-KcLMGohVxY\">1. \u5b89\u88dd ISAPI \u64f4\u5c55<\/h3>\n<p>\u5728 IIS \u4e2d\uff0c\u60a8\u9700\u8981\u5b89\u88dd ISAPI \u64f4\u5c55\u4ee5\u652f\u6301 Python \u8173\u672c\u3002\u6253\u958b IIS \u7ba1\u7406\u5668\uff0c\u9078\u64c7\u60a8\u7684\u7db2\u7ad9\uff0c\u7136\u5f8c\u5728\u53f3\u5074\u7684\u529f\u80fd\u9762\u677f\u4e2d\u627e\u5230\u201cISAPI \u548c CGI \u9650\u5236\u201d\u3002<\/p>\n<ul>\n<li>\u9ede\u64ca\u201c\u6dfb\u52a0\u201d\u4ee5\u6dfb\u52a0\u65b0\u7684 ISAPI \u64f4\u5c55\u3002<\/li>\n<li>\u5728\u201c\u53ef\u57f7\u884c\u6587\u4ef6\u201d\u4e2d\u8f38\u5165 Python \u7684\u5b89\u88dd\u8def\u5f91\uff0c\u4f8b\u5982\uff1a<code>C:Python27python.exe<\/code>\u3002<\/li>\n<li>\u5728\u201c\u63cf\u8ff0\u201d\u4e2d\u8f38\u5165\u4e00\u500b\u6613\u65bc\u8b58\u5225\u7684\u540d\u7a31\uff0c\u4f8b\u5982\u201cPython ISAPI\u201d\u3002<\/li>\n<li>\u78ba\u4fdd\u9078\u4e2d\u201c\u5141\u8a31\u201d\u9078\u9805\uff0c\u7136\u5f8c\u9ede\u64ca\u201c\u78ba\u5b9a\u201d\u3002<\/li>\n<\/ul>\n<h3 id=\"2-%e9%85%8d%e7%bd%ae%e8%99%95%e7%90%86%e7%a8%8b%e5%ba%8f%e6%98%a0%e5%b0%84-KcLMGohVxY\">2. \u914d\u7f6e\u8655\u7406\u7a0b\u5e8f\u6620\u5c04<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e\u8655\u7406\u7a0b\u5e8f\u6620\u5c04\uff0c\u4ee5\u4fbf IIS \u80fd\u5920\u8b58\u5225 Python \u8173\u672c\uff1a<\/p>\n<ul>\n<li>\u5728 IIS \u7ba1\u7406\u5668\u4e2d\uff0c\u9078\u64c7\u60a8\u7684\u7db2\u7ad9\uff0c\u7136\u5f8c\u9ede\u64ca\u201c\u8655\u7406\u7a0b\u5e8f\u6620\u5c04\u201d\u3002<\/li>\n<li>\u9ede\u64ca\u201c\u6dfb\u52a0\u6a21\u584a\u6620\u5c04\u201d\u3002<\/li>\n<li>\u5728\u201c\u8acb\u6c42\u8def\u5f91\u201d\u4e2d\u8f38\u5165 <code>*.py<\/code>\u3002<\/li>\n<li>\u5728\u201c\u6a21\u584a\u201d\u4e2d\u9078\u64c7\u201cIsapiModule\u201d\u3002<\/li>\n<li>\u5728\u201c\u53ef\u57f7\u884c\u6587\u4ef6\u201d\u4e2d\u8f38\u5165 Python \u7684\u5b89\u88dd\u8def\u5f91\uff0c\u4f8b\u5982\uff1a<code>C:Python27python.exe<\/code>\u3002<\/li>\n<li>\u5728\u201c\u540d\u7a31\u201d\u4e2d\u8f38\u5165\u4e00\u500b\u6613\u65bc\u8b58\u5225\u7684\u540d\u7a31\uff0c\u4f8b\u5982\u201cPython Handler\u201d\u3002<\/li>\n<li>\u9ede\u64ca\u201c\u78ba\u5b9a\u201d\uff0c\u7136\u5f8c\u9078\u64c7\u201c\u662f\u201d\u4ee5\u5141\u8a31\u6b64\u6620\u5c04\u3002<\/li>\n<\/ul>\n<h3 id=\"3-%e9%85%8d%e7%bd%ae%e7%b6%b2%e7%ab%99%e6%ac%8a%e9%99%90-KcLMGohVxY\">3. \u914d\u7f6e\u7db2\u7ad9\u6b0a\u9650<\/h3>\n<p>\u78ba\u4fdd\u60a8\u7684\u7db2\u7ad9\u76ee\u9304\u5177\u6709\u57f7\u884c Python \u8173\u672c\u7684\u6b0a\u9650\u3002\u53f3\u9375\u55ae\u64ca\u7db2\u7ad9\u76ee\u9304\uff0c\u9078\u64c7\u201c\u5c6c\u6027\u201d\uff0c\u7136\u5f8c\u5728\u201c\u5b89\u5168\u201d\u9078\u9805\u5361\u4e2d\u6dfb\u52a0\u9069\u7576\u7684\u7528\u6236\u6b0a\u9650\u3002<\/p>\n<h2 id=\"%e6%b8%ac%e8%a9%a6-python-%e8%85%b3%e6%9c%ac-KcLMGohVxY\">\u6e2c\u8a66 Python \u8173\u672c<\/h2>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u914d\u7f6e\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684 Python \u8173\u672c\u4f86\u6e2c\u8a66\u914d\u7f6e\u662f\u5426\u6210\u529f\u3002\u5275\u5efa\u4e00\u500b\u540d\u70ba <code>test.py<\/code> \u7684\u6587\u4ef6\uff0c\u4e26\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u78bc\uff1a<\/p>\n<pre><code>print(\"Content-Type: text\/html\")\nprint()\nprint(\"<h1 id=\"hello-world-KcLMGohVxY\">Hello, World!<\/h1>\")<\/code><\/pre>\n<p>\u5c07\u6b64\u6587\u4ef6\u653e\u7f6e\u5728\u60a8\u7684\u7db2\u7ad9\u6839\u76ee\u9304\u4e2d\uff0c\u7136\u5f8c\u5728\u700f\u89bd\u5668\u4e2d\u8a2a\u554f <code>http:\/\/yourdomain\/test.py<\/code>\u3002\u5982\u679c\u4e00\u5207\u914d\u7f6e\u6b63\u78ba\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230\u201cHello, World!\u201d\u7684\u8a0a\u606f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-KcLMGohVxY\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904e\u4ee5\u4e0a\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u6210\u529f\u5730\u5728 IIS 7.5 \u4e0a\u914d\u7f6e Python \u74b0\u5883\uff0c\u4e26\u904b\u884c Python \u8173\u672c\u3002\u9019\u6a23\u7684\u914d\u7f6e\u4e0d\u50c5\u80fd\u5920\u64f4\u5c55\u60a8\u7684\u7db2\u7ad9\u529f\u80fd\uff0c\u9084\u80fd\u63d0\u9ad8\u958b\u767c\u6548\u7387\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u4f86\u90e8\u7f72\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\uff0c\u4eab\u53d7\u66f4\u7a69\u5b9a\u7684\u6027\u80fd\u548c\u66f4\u9ad8\u7684\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728 IIS 7.5 \u4e0a\u914d\u7f6e Python \u8173\u672c\uff0c\u5be6\u73fe\u9ad8\u6548\u57f7\u884c\uff0c\u63d0\u5347\u7db2\u7ad9\u6027\u80fd\u8207\u529f\u80fd\u3002<\/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-49396","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49396","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=49396"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49396\/revisions"}],"predecessor-version":[{"id":49397,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/49396\/revisions\/49397"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=49396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=49396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=49396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}