我是 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>'
Run Code Online (Sandbox Code Playgroud)
但是,它的错误如下所述
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
Run Code Online (Sandbox Code Playgroud)
我觉得这个问题可能与权限无关,因为我可以浏览 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>')
Run Code Online (Sandbox Code Playgroud)
*.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>
Run Code Online (Sandbox Code Playgroud)
设置站点文件夹( ) 和python 文件夹( ) 的iis_iusrs权限。确保启用匿名身份验证,并将应用程序池设置为应用程序池标识。完成所有更改后,重新启动 IIS 服务器并浏览站点。iusrc:\pythonappC:\Python37-32
| 归档时间: |
|
| 查看次数: |
3458 次 |
| 最近记录: |