在 Windows XP 上运行 Python CGI 脚本

发布于 2024-08-27 20:49:52 字数 518 浏览 2 评论 0原文

我有一台 Windows XP 计算机,通过 VisualSVNServer 安装安装了 Apache。我是 。尝试让一个简单的 python cgi 脚本在我的浏览器中运行,例如 http://build.procepts.com.au:8080/hg/cgi-bin/test.cgi。然而,尽管尝试了所有推荐的方法,浏览器仍然只显示 cgi 脚本中的纯文本。在许多其他尝试的解决方案中,我遵循了此处中包含的说明。我的最终目标是能够使用 Apache Web 服务器从新的 Mercurial 安装中为存储库提供服务。鉴于 Apache 已经从 VisualSVNServer 安装,我想我不妨使用它。还有其他技巧可以让这个工作吗?

I have a Windows XP machine that has Apache installed via a VisualSVNServer installation. I am . trying to get a simple python cgi script to run in my browser e.g. http://build.procepts.com.au:8080/hg/cgi-bin/test.cgi. However despite trying all the recommended approaches the browser only ever displays the plain text from the cgi script. Amongst many other attempted solutions I have followed the instructions contained here. My ultimate aim is to be able to use the Apache web server to serve repositories from a new Mercurial installation. Seeing as Apache is already installed from VisualSVNServer I thought I might as well make use of it. Is there some other trick to get this working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阳光①夏 2024-09-03 20:49:52

VisualSVNServer 附带的 apache 服务器是一个最小的构建,支持足以服务 SVN 存储库。它不包括 cgi 支持。

也就是说,添加 cgi 支持(或任何其他与此相关的模块)非常容易。

特别是对于 CGI 支持,您需要获取为 Apache 2.2 Win32 构建的“mod_cgi.so”并将其放置在“C:\Program Files\VisualSVN Server\bin”中,然后添加:

LoadModule cgi_module bin/mod_cgi.so
ScriptAlias /cgi-bin/ cgi-bin/

到“C:\Program Files\VisualSVN”服务器\conf\httpd-custom.conf”。重新启动 VisualSVN,它应该开始工作。

The apache server that comes with VisualSVNServer is a minimal build supporting just enough to serve SVN repositories. It does not include cgi support.

That said, it's pretty easy to add cgi support (or any other module for that matter).

For CGI support specifically, you'll need to obtain "mod_cgi.so" built for Apache 2.2 Win32 and place it in "C:\Program Files\VisualSVN Server\bin", then add:

LoadModule cgi_module bin/mod_cgi.so
ScriptAlias /cgi-bin/ cgi-bin/

to "C:\Program Files\VisualSVN Server\conf\httpd-custom.conf". Restart VisualSVN and it should start working.

相思碎 2024-09-03 20:49:52

我不确定它是否适用于 VisualSVNServer,但在通常的 Apache 中,您至少需要以下内容:

  1. 在 Apache 配置中取消注释加载 CGI 模块:

    LoadModule cgi_module module/mod_cgi.so (或类似)
    
  2. 允许在目录中执行 CGI 脚本并为 py 脚本添加处理程序:

    <目录/path/to/scripts/directory>
        选项+ExecCGI
        AddHandler cgi-脚本 py
    
    
  3. 在执行的脚本中插入 shebang 行:

    #!/usr/local/bin/python
    

I am not sure if it applies to the VisualSVNServer, but in ususal Apache you will need at least the following:

  1. Uncomment loading CGI module in Apache config:

    LoadModule cgi_module modules/mod_cgi.so (or similar)
    
  2. Allow executing of CGI scripts in your directory and add a handler for py scripts:

    <Directory /path/to/scripts/directory>
        Options +ExecCGI
        AddHandler cgi-script py
    </Directory>
    
  3. Insert a shebang line in the executed script:

    #!/usr/local/bin/python
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文