![](/img/trans.png)
[英]How to deploy python flask application in conda base environment on IIS server?
[英]How to deploy Python application using CGI on IIS?
我是 python 的新手,我尝试在 IIS 上部署一个简单的 hello python 应用程序,我遵循了这个 URL
https://support.sisense.com/hc/en-us/community/posts/115007362727-Installing-Python-on-IIS
你好.py
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
但是,它的错误如下所述
HTTP Error 401.3 - Unauthorized
You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server
我觉得问题可能与权限无关,因为我可以浏览 hello.html
我尝试了 SO 中提供的一些解决方案来解决问题,但没有任何效果。 任何帮助都受到高度赞赏
要使用 IIS 配置 Python,您可以尝试按照以下步骤操作:
https://www.python.org/downloads/windows/
hello.py
文件:print("Content-type:text/html\r\n\r\n")
print('<html>')
print('<head>')
print('<title>Hello Word - First CGI Program</title>')
print('</head>')
print('<body>')
print('<h2>Hello Word! This is my first CGI program</h2>')
print('</body>')
print('</html>')
*.py
,并将其映射到c:\\Python37-32\\python.exe %s %s
。
确保启用目录浏览。
web.config
文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="python" path="*.py" verb="*" modules="CgiModule" scriptProcessor="C:\Python37-32\python.exe %s %s" resourceType="File" />
</handlers>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
将iis_iusrs
和iusr
权限设置为站点文件夹( c:\\pythonapp
)和 python 文件夹( C:\\Python37-32
)。 确保启用匿名身份验证,并将应用程序池设置为应用程序池标识。 完成所有更改后,重新启动 IIS 服务器并浏览站点。
请参阅此链接https://www.storehubs.com/Blog/deploy-python-flask-application-iis/ 。 安装python3(32位)并使用virtualenv进行部署。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.