{"id":215,"date":"2021-01-02T12:30:21","date_gmt":"2021-01-02T06:30:21","guid":{"rendered":"http:\/\/www.jichangqing.net\/wordpress\/?p=215"},"modified":"2021-01-02T12:30:21","modified_gmt":"2021-01-02T06:30:21","slug":"windows-server-iis%e9%83%a8%e7%bd%b2django%e8%af%a6%e7%bb%86%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"http:\/\/www.jichangqing.net\/wordpress\/?p=215","title":{"rendered":"Windows server iis\u90e8\u7f72Django\u8be6\u7ec6\u64cd\u4f5c"},"content":{"rendered":"<p style=\"color: #3e454c;\">\u6559\u7a0b\u57fa\u4e8eWindows server2012+Python3.6+IIS\u4e4b\u4e0a\u90e8\u7f72django\u7684\uff0c\u540c\u6837\u9002\u7528\u4e8eserver2012\u4e4b\u4e0a\u7684\u7248\u672c\u670d\u52a1\u5668\u548cwindows7\u4ee5\u4e0a\u7684windows\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p style=\"color: #3e454c;\"><span style=\"color: #c00000;\"><span style=\"font-weight: bold; color: inherit;\">\u63d0\u793a\uff1a<\/span><\/span>Python\u4e0d\u8981\u5b89\u88c5\u5728windows\u7528\u6237\u76ee\u5f55\u4e0b\uff0c\u9879\u76ee\u4e5f\u4e0d\u8981\u653e\u5728windows\u7528\u6237\u76ee\u5f55\u4e0b\uff0c\u8fd9\u6837\u5c31\u80fd\u907f\u514d\u51fa\u5f88\u591a\u95ee\u9898\u3002<\/p>\n<p style=\"color: #3e454c;\">\u5982\u679c\u89c9\u5f97\u770b\u6587\u5b57\u6ca1\u610f\u601d\uff0c\u60f3\u770b\u89c6\u9891\u6559\u7a0b\u7684\uff0c\u8bf7\u70b9\u51fb\u8fd9\u91cc\uff1a<a style=\"color: #16af59;\" href=\"https:\/\/mp.weixin.qq.com\/s\/vF8yC0WUM9B0PmsQSMutiQ\" target=\"_blank\">Django\u9879\u76ee\u90e8\u7f72\u89c6\u9891\u6559\u7a0b<\/a><\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">1\u3001\u5b89\u88c5IIS\u548cCGI<\/span><\/p>\n<p style=\"color: #3e454c;\">\u6253\u5f00\u670d\u52a1\u5668\u7ba1\u7406\u5668\uff0c\u9009\u62e9\u6dfb\u52a0\u89d2\u8272\u548c\u529f\u80fd\uff0c\u9009\u62e9\u8981\u6dfb\u52a0\u7684\u670d\u52a1\u5668\u89d2\u8272\uff08<span style=\"font-weight: bold; color: inherit;\">WEB\u670d\u52a1\u5668IIS<\/span>\uff09\uff0c\u7136\u540e\u5b89\u88c5<\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/11_20181019114928_146.jpg\" alt=\"11.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/1_20181019114218_227.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/2_20181019114218_175.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/3_20181019114218_100.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\">IIS\u5b89\u88c5\u6210\u529f\u4e4b\u540e\uff0c\u7136\u540e\u5b89\u88c5CGI\uff0c\u518d\u6b21\u9009\u62e9<span style=\"font-weight: bold; color: inherit;\">\u6dfb\u52a0\u89d2\u8272\u548c\u529f\u80fd<\/span>\uff0c\u627e\u5230\u4e4b\u524d\u5b89\u88c5\u7684<span style=\"font-weight: bold; color: inherit;\">WEB\u670d\u52a1\u5668IIS<\/span>\uff0c\u70b9\u51fb\u5b83\u3002<\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/4_20181019114218_323.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\">\u5728\u5c55\u5f00\u7684\u9009\u9879\u91cc\u627e\u5230<span style=\"font-weight: bold; color: inherit;\">WEB\u670d\u52a1\u5668<\/span>\uff0c\u70b9\u51fb\u5b83\uff0c\u627e\u5230<span style=\"font-weight: bold; color: inherit;\">\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1<\/span>\u70b9\u51fb\u5728\u5c55\u5f00\u7684\u5217\u8868\u91cc\u627e\u5230<span style=\"font-weight: bold; color: inherit;\">CGI<\/span>\uff0c\u52fe\u9009\uff0c\u7136\u540e\u4e0b\u4e00\u6b65\uff0c\u5b89\u88c5\u5b83\u3002<\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/5_20181019114218_506.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/6_20181019114218_563.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\">\u5b89\u88c5\u597dCGI\u4e4b\u540e\uff0c\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165http:\/\/127.0.0.1\u00a0 \u8bbf\u95eeIIS\uff0c\u5982\u679c\u51fa\u73b0\u5982\u4e0b\u9875\u9762\uff0c\u8bf4\u660eIIS\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" src=\"https:\/\/www.django.cn\/media\/upimg\/7_20181019114218_889.jpg\" alt=\"\" \/><\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">2\u3001\u5b89\u88c5Python3<\/span><\/p>\n<p style=\"color: #3e454c;\">\u5728C\u76d8\u5efa\u7acbpython\u76ee\u5f55\uff0c\u7136\u540e\u4ecePython\u5b98\u7f51\u4e0b\u8f7dWindows\u7248\u672c\u768464\u4f4d\u7684Python\u5b89\u88c5\u5305\uff0c\u5e76\u5b89\u88c5\u5b83\u3002\u5177\u4f53\u53ef\u4ee5\u53c2\u8003\u6587\u7ae0\uff1a<a style=\"color: #16af59;\" href=\"https:\/\/www.django.cn\/article\/show-20.html\" target=\"_blank\">python3\u5b89\u88c5\u8be6\u7ec6\u6b65\u9aa4<\/a><\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">3\u3001\u5b89\u88c5wfastcgi<\/span><\/p>\n<p style=\"color: #3e454c;\">\u5728Windows\u4e0b\uff0c\u6211\u4eec\u6ca1\u6cd5\u4f7f\u7528uwsgi\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528wfastcgi\u66ff\u4ee3\u5b83\uff0c\u6253\u5f00CMD\u7a97\u53e3\uff0c\u8f93\u5165\u547d\u4ee4\u5b89\u88c5wfastcgi\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false hljs nginx\" style=\"color: #191919;\"><span class=\"hljs-attribute\" style=\"color: #dd4a68;\">pip<\/span>\u00a0install\u00a0wfastcgi<\/pre>\n<p style=\"color: #3e454c;\">\u5b89\u88c5\u6210\u529f\u4e4b\u540e\uff0c\u901a\u8fc7\u4e0b\u9762\u547d\u4ee4\u542f\u52a8\u5b83\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false hljs\" style=\"color: #191919;\">wfastcgi-enable<\/pre>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/1_20181019120549_439.jpg\" alt=\"1.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">\u5982\u4e0a\u56fe\uff0c\u542f\u52a8\u6210\u529f\u4e4b\u540e\uff0c\u5b83\u4f1a\u628aPython\u8def\u5f84\u548cwfastcgi\u7684\u8def\u5f84\u663e\u793a\u51fa\u6765\uff0c\u6211\u4eec\u9700\u8981\u628a\u8fd9\u4e2a\u8def\u5f84\u590d\u5236\u51fa\u6765\uff0c\u4fdd\u5b58\u597d\uff0c\u540e\u8fb9\u7528\u5f97\u7740\u3002<\/p>\n<pre class=\"brush:bash;toolbar:false hljs\" style=\"color: #191919;\">c:\\python\\python.exe|c:\\python\\lib\\site-packages\\wfastcgi.py<\/pre>\n<p style=\"color: #3e454c;\">\u6ce8\u610f\uff1a\u4e0a\u9762\u7684\u8def\u5f84\uff0c\u662f\u7531Python\u89e3\u91ca\u5668\u7684\u8def\u5f84\u548c\u201c|\u201d\u4ee5\u53ca\u201cwfastcgi.py\u201d\u6587\u4ef6\u8def\u5f84\u7ec4\u6210\u3002<\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">4\u3001\u5728IIS\u91cc\u6dfb\u52a0\u9879\u76ee\u7f51\u7ad9<br style=\"color: inherit;\" \/><\/span><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/1_20181019121524_688.jpg\" alt=\"1.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">\u628a\u6211\u4eec\u672c\u5730\u9879\u76ee\u6e90\u7801\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u76f8\u5e94\u7684\u76ee\u5f55\u91cc\u3002<\/p>\n<p style=\"color: #3e454c;\"><span style=\"color: #ff0000;\">\u7559\u610f\uff1a<\/span>\u642c\u8fc1\u9879\u76ee\u7684\u65f6\u5019\u6211\u4eec\u5148\u5728\u672c\u5730\u6362\u5230\u9879\u76ee\u8def\u5f84\u4e0b\uff0c\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u628a\u5f53\u524d\u9879\u76ee\u73af\u5883\u7684\u8f6f\u4ef6\u5305\u4fe1\u606f\u548c\u4f9d\u8d56\u8f6f\u4ef6\u5bfc\u51fa\u5230requirements.txt\u6587\u4ef6\u91cc\u3002<\/p>\n<pre class=\"brush:bash;toolbar:false hljs css\" style=\"color: #191919;\"><span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">pip<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">freeze<\/span>\u00a0&gt;\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">requirements<\/span><span class=\"hljs-selector-class\" style=\"color: #669900;\">.txt<\/span><\/pre>\n<p style=\"color: #3e454c;\">\u7136\u540e\u628a\u9879\u76ee\u6e90\u7801\u6253\u5305\uff0c\u4e0a\u4f20\u5230\u670d\u52a1\u5668\u7684\u7f51\u7ad9\u8def\u5f84\u91cc\uff0c\u89e3\u538b\u3002<\/p>\n<p style=\"color: #3e454c;\">\u4e4b\u540e\u6253\u5f00CMD\u5207\u6362\u5230\u9879\u76ee\u6587\u4ef6\u5939\u8def\u5f84\uff0c\u8f93\u5165\u4e0b\u9762\u547d\u4ee4\uff0c\u5b89\u88c5\u9879\u76ee\u6240\u9700\u8981\u4f9d\u8d56\u548c\u8f6f\u4ef6\u5305\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false hljs css\" style=\"color: #191919;\"><span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">pip<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">install<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">-r<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">requirements<\/span><span class=\"hljs-selector-class\" style=\"color: #669900;\">.txt<\/span><\/pre>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/2_20181019122204_696.jpg\" alt=\"2.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">\u5982\u679c\u4f7f\u7528\u7684\u662fMysql\u6570\u636e\u5e93\uff0c\u8bf7\u81ea\u884c\u5b89\u88c5Mysql\u548c\u5bfc\u5165\u6570\u636e\uff0c\u8fd9\u91cc\u5c31\u4e0d\u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<p style=\"color: #3e454c;\">\n<p style=\"color: #3e454c;\"><span style=\"color: #c00000;\"><span style=\"font-weight: bold; color: inherit;\">\u6ce8\u610f\uff1a<\/span><\/span>\u9879\u76ee\u6240\u9700\u8981\u7684\u5e93\u548c\u4f9d\u8d56\u8f6f\u4ef6\u90fd\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\uff0c\u8bf7\u5148\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u8fd0\u884c\u4e00\u4e0b\u9879\u76ee\uff0c\u786e\u4fdd\u6e90\u7801\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u4e4b\u540e\u518d\u8fdb\u884c\u4e0b\u4e00\u6b65\u3002<\/p>\n<pre class=\"brush:bash;toolbar:false hljs css\" style=\"color: #191919;\"><span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">python<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">manage<\/span><span class=\"hljs-selector-class\" style=\"color: #669900;\">.py<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">runserver<\/span><\/pre>\n<p style=\"color: #3e454c;\">\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">5\u3001\u5728\u9879\u76ee\u6839\u76ee\u5f55\u91cc\u65b0\u5efa\u4e00\u4e2aweb.config\u914d\u7f6e\u6587\u4ef6\uff0c\u653e\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/span><\/p>\n<pre class=\"brush:bash;toolbar:false hljs xml\" style=\"color: #191919;\"><span class=\"php\" style=\"color: inherit;\"><span class=\"hljs-meta\" style=\"color: inherit;\">&lt;?<\/span>xml\u00a0version=<span class=\"hljs-string\" style=\"color: #669900;\">\"1.0\"<\/span>\u00a0encoding=<span class=\"hljs-string\" style=\"color: #669900;\">\"UTF-8\"<\/span><span class=\"hljs-meta\" style=\"color: inherit;\">?&gt;<\/span><\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">configuration<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">system.webServer<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">handlers<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">add<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">name<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"Python\u00a0FastCGI\"<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">path<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"*\"<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">verb<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"*\"<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">modules<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"FastCgiModule\"<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">scriptProcessor<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"&lt;Path\u00a0to\u00a0Python&gt;\\python.exe|&lt;Path\u00a0to\u00a0Python&gt;\\lib\\site-packages\\wfastcgi.py\"<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">resourceType<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"Unspecified\"<\/span>\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">requireAccess<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"Script\"<\/span>\/&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">handlers<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">system.webServer<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">appSettings<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">add<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">key<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"WSGI_HANDLER\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">value<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"django.core.wsgi.get_wsgi_application()\"<\/span>\u00a0\/&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">add<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">key<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"PYTHONPATH\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">value<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"&lt;Path\u00a0to\u00a0Django\u00a0App&gt;\"<\/span>\u00a0\/&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">add<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">key<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"DJANGO_SETTINGS_MODULE\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">value<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"&lt;Django\u00a0App&gt;.settings\"<\/span>\u00a0\/&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">appSettings<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">configuration<\/span>&gt;<\/span><\/pre>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/3_20181019122855_339.jpg\" alt=\"3.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">\u7559\u610f\uff1a\u8fd9\u91cc\u9762\u6211\u6807\u8bb0\u7684\u4e09\u4e2a\u5730\u65b9\uff0c\u6211\u4eec\u9700\u8981\u4fee\u6539\u3002<\/p>\n<p style=\"color: #3e454c;\">1\u3001\u66ff\u6362\u4e3a\u6211\u4eec\u4e4b\u524d\u6211\u4eec\u542f\u52a8wfastcgi\u65f6\u590d\u5236\u7684python\u548cwfastcgi\u7684\u8def\u5f84\u3002<\/p>\n<p style=\"color: #3e454c;\">2\u3001\u586b\u5199\u6211\u4eec\u7684\u9879\u76ee\u8def\u5f84\u3002<\/p>\n<p style=\"color: #3e454c;\">3\u3001\u586b\u5199settings.py\u7684\u4f4d\u7f6e\u3002&lt;django App&gt;\u4fee\u6539\u6210\u6211\u4eec\u7684settings.py\u6240\u5728\u76ee\u5f55\u7684\u76ee\u5f55\u540d\u5373\u53ef\u3002<\/p>\n<p style=\"color: #3e454c;\">\u4fee\u6539\u5b8c\u6bd5\uff0c\u542f\u52a8IIS\uff0c\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165http:\/\/127.0.0.1\u00a0 \u5c31\u80fd\u8bbf\u95ee\u7f51\u7ad9\u3002<\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">6\u3001\u5982\u679c\u8bbf\u95eeIIS\u51fa\u73b0\u5982\u4e0b\u9519\u8bef\uff1a<\/span><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"undefined\" src=\"https:\/\/www.django.cn\/media\/upimg\/4_20181019124050_502.jpg\" alt=\"4.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">HTTP \u9519\u8bef 500.19 Internal Server Error<\/p>\n<p style=\"color: #3e454c;\">\u51fa\u73b0\u8fd9\u6837\u7684\u60c5\u51b5\u662f\u56e0\u4e3aIIS7\u4e4b\u540e\u7684\u7248\u672c\u90fd\u91c7\u7528\u4e86\u66f4\u5b89\u5168\u7684 web.config \u7ba1\u7406\u673a\u5236\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4f1a\u9501\u4f4f\u914d\u7f6e\u9879\u4e0d\u5141\u8bb8\u66f4\u6539\u3002\u6211\u4eec\u628a\u5b83\u89e3\u9501\u4e86\u5c31OK\u3002<\/p>\n<p style=\"color: #3e454c;\">\u6253\u5f00CMD\uff0c\u5728\u91cc\u9762\u4f9d\u6b21\u8f93\u5165\u4e0b\u9762\u4e24\u4e2a\u547d\u4ee4\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false hljs sql\" style=\"color: #191919;\">%windir%\\system32\\inetsrv\\appcmd\u00a0<span class=\"hljs-keyword\" style=\"color: #0077aa;\">unlock<\/span>\u00a0config\u00a0-<span class=\"hljs-keyword\" style=\"color: #0077aa;\">section<\/span>:system.webServer\/handlers\u00a0\r\n\r\n%windir%\\system32\\inetsrv\\appcmd\u00a0<span class=\"hljs-keyword\" style=\"color: #0077aa;\">unlock<\/span>\u00a0config\u00a0-<span class=\"hljs-keyword\" style=\"color: #0077aa;\">section<\/span>:system.webServer\/modules<\/pre>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/5_20181019124423_728.jpg\" alt=\"5.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">\u89e3\u9664\u4e86\u9501\u5b9a\u4e4b\u540e\uff0c\u518d\u8bbf\u95ee\u7f51\u7ad9\u5c31\u80fd\u6b63\u5e38\u663e\u793a\u4e86\u3002<\/p>\n<p style=\"color: #3e454c;\">\u8fd8\u6709\u79cd\u60c5\u51b5\uff1a\u6709\u65f6\u5019\u8bbf\u95ee\u9875\u9762\uff0c\u6216\u8005\u5355\u72ec\u8bbf\u95ee\u7f51\u7ad9\u540e\u53f0\u51fa\u73b0400\u9519\u8bef\uff0c\u8fd9\u4e2a\u65f6\u5019\u53ef\u80fd\u662f\u56e0\u4e3a\u6ca1\u6709\u7ed9\u7f51\u7ad9\u6743\u9650\u7684\u539f\u56e0\u3002\u6211\u4eec\u6253\u5f00IIS\uff0c\u627e\u5230\u7f51\u7ad9\uff0c\u53f3\u952e\uff0c\u7f16\u8f91\u6743\u9650\uff0c\u7ed9IIS\u7528\u6237\u6dfb\u52a0\u4fee\u6539\u548c\u5199\u5165\u6743\u9650\u3002\u5c31\u80fd\u6b63\u5e38\u8bbf\u95ee\u3002<\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"undefined\" src=\"https:\/\/www.django.cn\/media\/upimg\/1_20181019124741_628.png\" alt=\"1.png\" \/><\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">7\u3001\u7ed9\u9759\u6001\u8d44\u6e90\u6dfb\u52a0\u865a\u62df\u76ee\u5f55<br style=\"color: inherit;\" \/><\/span><\/p>\n<p style=\"color: #3e454c;\">\u7f51\u7ad9\u80fd\u8bbf\u95ee\u4e86\uff0c\u4f46\u6211\u4eec\u7684\u524d\u7aef\u6837\u5f0f\u663e\u793a\u6709\u95ee\u9898\u3002\u90a3\u662f\u56e0\u4e3a\u6211\u4eec\u6ca1\u6709\u5728IIS\u91cc\u6307\u5b9a\u6211\u4eec\u7684\u9759\u6001\u8d44\u6e90\u76ee\u5f55\uff0c\u6211\u4eec\u7ed9\u5b83\u6dfb\u52a0\u4e0a\u865a\u62df\u76ee\u5f55\u5c31\u80fd\u89e3\u51b3\u3002<\/p>\n<p style=\"color: #3e454c;\">\u6b65\u9aa4\uff1a<\/p>\n<p style=\"color: #3e454c;\">1\u3001\u6dfb\u52a0\u865a\u62df\u76ee\u5f55\uff0c\u5728IIS\u627e\u9009\u4e2d\u7f51\u7ad9\u9879\u76ee\u540d\uff0c\u53f3\u952e&#8211;\u6dfb\u52a0\u865a\u62df\u8def\u5f84<\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/6_20181019125328_295.jpg\" alt=\"6.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"undefined\" src=\"https:\/\/www.django.cn\/media\/upimg\/7_20181019125438_379.jpg\" alt=\"7.jpg\" \/><\/p>\n<p style=\"color: #3e454c;\">\u6dfb\u52a0\u865a\u62df\u76ee\u5f55\u65f6\uff0c\u522b\u540d\u653e\u4e0e\u4f60settings\u91cc\u8bbe\u7f6e\u7684\u4e00\u81f4\uff0c\u6bd4\u5982&#8217;static&#8217;\uff0c\u7269\u7406\u8def\u5f84\u5c31\u662f\u9759\u6001\u8d44\u6e90\u7684\u5b9e\u9645\u76ee\u5f55\u3002<\/p>\n<p style=\"color: #3e454c;\">2\u3001\u5728static\u76ee\u5f55\u91cc\u65b0\u5efa\u4e00\u4e2aweb.config\u6587\u4ef6\uff0c\u7136\u540e\u5199\u5165\u4e0b\u9762\u7684\u5185\u5bb9\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false hljs xml\" style=\"color: #191919;\"><span class=\"php\" style=\"color: inherit;\"><span class=\"hljs-meta\" style=\"color: inherit;\">&lt;?<\/span>xml\u00a0version=<span class=\"hljs-string\" style=\"color: #669900;\">\"1.0\"<\/span>\u00a0encoding=<span class=\"hljs-string\" style=\"color: #669900;\">\"UTF-8\"<\/span><span class=\"hljs-meta\" style=\"color: inherit;\">?&gt;<\/span><\/span>\r\n\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">configuration<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">system.webServer<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-comment\" style=\"color: #708090;\">&lt;!--\u00a0this\u00a0configuration\u00a0overrides\u00a0the\u00a0FastCGI\u00a0handler\u00a0to\u00a0let\u00a0IIS\u00a0serve\u00a0the\u00a0static\u00a0files\u00a0--&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">handlers<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">clear<\/span>\/&gt;<\/span>\r\n\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;<span class=\"hljs-name\" style=\"color: #990055;\">add<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">name<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"StaticFile\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">path<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"*\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">verb<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"*\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">modules<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"StaticFileModule\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">resourceType<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"File\"<\/span>\u00a0<span class=\"hljs-attr\" style=\"color: #0077aa;\">requireAccess<\/span>=<span class=\"hljs-string\" style=\"color: #669900;\">\"Read\"<\/span>\u00a0\/&gt;<\/span>\r\n\u00a0\u00a0\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">handlers<\/span>&gt;<\/span>\r\n\u00a0\u00a0\u00a0<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">system.webServer<\/span>&gt;<\/span>\r\n<span class=\"hljs-tag\" style=\"color: #999999;\">&lt;\/<span class=\"hljs-name\" style=\"color: #990055;\">configuration<\/span>&gt;<\/span><\/pre>\n<p style=\"color: #3e454c;\">\u91cd\u542fIIS\uff0c\u8bbf\u95ee\u7f51\u7ad9\uff0c\u524d\u7aef\u5c31\u80fd\u6b63\u5e38\u663e\u793a\u3002<\/p>\n<p style=\"color: #3e454c;\"><span style=\"font-weight: bold; color: inherit;\">8\u3001\u7ba1\u7406\u540e\u53f0\u6837\u5f0f\u4e22\u5931\u89e3\u51b3<br style=\"color: inherit;\" \/><\/span><\/p>\n<p style=\"color: #3e454c;\">\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u90e8\u7f72\u7684\u65f6\u5019\u7ba1\u7406\u540e\u53f0\u6837\u5f0f\u662f\u4e0d\u80fd\u6b63\u5e38\u663e\u793a\u7684\uff0c\u6211\u4eec\u9700\u8981\u6536\u96c6\u8fd9\u4e9b\u6837\u5f0f\u5230\u9879\u76ee\u91cc\u53bb\uff0c\u624d\u80fd\u6b63\u5e38\u663e\u793a\u3002<\/p>\n<p style=\"color: #3e454c;\">\u6b65\u9aa4\uff1a<\/p>\n<p style=\"color: #3e454c;\">1\u3001\u5728settings.py\u91cc\u6dfb\u52a0STATIC_ROOT\u914d\u7f6e\u6307\u5b9a\u6536\u96c6\u8def\u5f84\u5982\uff1a<\/p>\n<pre class=\"brush:bash;toolbar:false hljs ini\" style=\"color: #191919;\"><span class=\"hljs-comment\" style=\"color: #708090;\">#\u6307\u5b9a\u6837\u5f0f\u6536\u96c6\u76ee\u5f55\uff0c\u8def\u5f84\u4e00\u822c\u4e3a\u9879\u76ee\u91cc\u7684static\u6587\u4ef6\u5939<\/span>\r\n<span class=\"hljs-attr\" style=\"color: #0077aa;\">STATIC_ROOT<\/span>\u00a0\u00a0=\u00a0os.path.join(BASE_DIR,\u00a0<span class=\"hljs-string\" style=\"color: #669900;\">'static'<\/span>)\r\n<span class=\"hljs-comment\" style=\"color: #708090;\">#\u6216<\/span>\r\n<span class=\"hljs-attr\" style=\"color: #0077aa;\">STATIC_ROOT<\/span>\u00a0=\u00a0<span class=\"hljs-string\" style=\"color: #669900;\">'C:\\python\\mysite\\static'<\/span><\/pre>\n<p style=\"color: #3e454c;\">\u7136\u540eCMD\u4e0b\u8fd0\u884c\u5982\u4e0b\u9762\u547d\u4ee4\uff0c\u8fdb\u884c\u6837\u5f0f\u91c7\u96c6\uff1a<\/p>\n<pre class=\"hljs css\" style=\"color: #191919;\"><span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">python<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">manage<\/span><span class=\"hljs-selector-class\" style=\"color: #669900;\">.py<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">collectstatic<\/span><\/pre>\n<p style=\"color: #3e454c;\">\u91c7\u96c6\u5b8c\u6210\u4e4b\u540e\uff0c\u5237\u65b0\u9875\u9762\u3002\u540e\u53f0\u6837\u5f0f\u6210\u529f\u663e\u793a\u3002\u81f3\u6b64\uff0c\u90e8\u7f72\u7ed3\u675f\u3002<\/p>\n<p style=\"color: #3e454c;\">\n<p style=\"color: #3e454c;\"><span style=\"color: #c00000;\"><span style=\"font-weight: bold; color: inherit;\">\u9519\u8bef\u6536\u96c6\uff1a<\/span><\/span><\/p>\n<ol class=\" list-paddingleft-2\" style=\"color: #3e454c;\">\n<li style=\"color: inherit;\">\n<p style=\"color: inherit;\">\u51fa\u73b0\u5982\u4e0b\u622a\u56fe\u7684\u9519\u8bef\u5927\u591a\u662f\u6e90\u7801\u4e0d\u80fd\u6b63\u5e38\u8fd0\u884c\u7684\u539f\u56e0\uff0c\u5148\u5728\u670d\u52a1\u5668\u9879\u76ee\u76ee\u5f55\u91cc\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff0c\u80fd\u8fd0\u884c\u518d\u8fdb\u884c\u4e0b\u4e00\u6b65\uff0c\u4e0d\u80fd\u8fd0\u884c\uff0c\u8bf7\u5148\u68c0\u67e5\u6e90\u7801\u3002<\/p>\n<\/li>\n<\/ol>\n<pre class=\"brush:bash;toolbar:false hljs css\" style=\"color: #191919;\"><span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">python<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">manage<\/span><span class=\"hljs-selector-class\" style=\"color: #669900;\">.py<\/span>\u00a0<span class=\"hljs-selector-tag\" style=\"color: #0077aa;\">runserver<\/span><\/pre>\n<p style=\"color: #3e454c;\">\n<p style=\"color: #3e454c;\"><img decoding=\"async\" style=\"color: inherit;\" title=\"\" src=\"https:\/\/www.django.cn\/media\/upimg\/20190818151237_20190818151550_707.png\" alt=\"20190818151237.png\" \/><\/p>\n<p style=\"color: #3e454c;\">\n<p style=\"color: #3e454c;\">\u5982\u679c\u80fd\u6b63\u5e38\u8fd0\u884c\u9879\u76ee\uff0c\u8bf7\u68c0\u67e5\u4e00\u4e0bPython\u5b89\u88c5\u8def\u5f84\uff0cPython\u4e0d\u8981\u5b89\u88c5\u5728\u67d0\u4e2a\u7528\u6237\u7684\u76ee\u5f55\u4e0b\uff0c\u8fd9\u6837\u5bb9\u6613\u5bfc\u81f4\u6743\u9650\u65b9\u9762\u7684\u95ee\u9898\u3002<\/p>\n<p style=\"color: #3e454c;\">from: https:\/\/www.django.cn\/article\/show-21.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6559\u7a0b\u57fa\u4e8eWindows server2012+Python3.6+IIS\u4e4b\u4e0a\u90e8\u7f72django\u7684\uff0c\u540c\u6837\u9002\u7528\u4e8eserver2012\u4e4b\u4e0a\u7684\u7248\u672c\u670d\u52a1\u5668\u548cwindows7\u4ee5\u4e0a\u7684windows\u64cd\u4f5c\u7cfb\u7edf\u3002 \u63d0\u793a\uff1aPython\u4e0d\u8981\u5b89\u88c5\u5728windows\u7528\u6237\u76ee &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-215","post","type-post","status-publish","format-standard","hentry","category-django"],"_links":{"self":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=215"}],"version-history":[{"count":1,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":216,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions\/216"}],"wp:attachment":[{"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jichangqing.net\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}