需要一个具有某些特定标准的 http 服务器

发布于 2024-07-15 02:33:37 字数 533 浏览 4 评论 0原文

我一直在为我的项目寻找网络服务器,但一直无法令自己满意。 我需要一个支持已编译的 CGI 脚本 (exe)、适用于 Windows 的 http 服务器,并且必须能够使用相对路径。 如果服务器可以尽可能最小/轻量级,那将是一个额外的好处。

到目前为止,我的搜索中最困难的部分是找到一个既支持 CGI 又支持相对路径的服务器。 当我说相对路径时,我指的是服务器根目录。 我希望能够将其与我的项目一起打包,因此 conf 文件中的路径不能是绝对的。

我唯一能满足所有标准的是 Abyss Web,但他们的许可证是专有的,并且只能免费供个人使用。

编辑: 我发现了我的方法的错误。 我通过 root 的 cmd 启动了该过程。 因此,apache 在conf 中使用的相对路径是相对于我所在的根目录的。 通过更改到根目录并在那里运行进程,一切都会像 gbjbaanb 提到的那样工作。 但我认为我的问题的背景可能仍然有效。 如果我将服务器作为程序(C# .NET)中的进程运行,那么“当前目录”是什么? 我是否必须确保在启动之前更改了当前目录环境变量?

I've been looking for a webserver for my project but I haven't been able to satisfy myself. I need a http server that has support for compiled CGI scripts (exe), for Windows, and must be able to use relative paths. It would be a bonus if the server could be a minimal/lightweight as possible.

The hardest part in my search thus far is finding a server that supports both CGI and has relative path support. When I say relative path, I mean the server root directory. I want to be able to pack this along with my project and therefore the paths in the conf files cannot be absolute.

The only one I've gotten to satisfy every criteria is Abyss Web but their license is proprietary and only free for personal use.

EDIT:
I have found the error in my ways. I started the process via cmd at root. Thus the relative paths apache was using in the conf was relative to where I was, at root. By changing to the root dir and running the process there, everything works as gbjbaanb has mentioned. But I suppose the context of my question is may still be valid. If I were to run the server as a process in a my program (C# .NET), what would be the 'current directory' then? Would I have to make sure I've changed the current directory environment variable prior to launching it?

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

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

发布评论

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

评论(2

赴月观长安 2024-07-22 02:33:37

阿帕奇出了什么问题? 您可以将 DocumentRoot 设置为任何目录(尽管我还没有在 C: 上的 Windows 上尝试过它)

它也适用于网络服务器根目录 - 不要以 / 开头该指令,它可以工作。

What's wrong with Apache? You can set DocumentRoot to any directory (though I've not tried it for Windows on C:)

It also does apply to the webserver root directory - don't begin the directive with a / and it works.

分分钟 2024-07-22 02:33:37

我已经快速启动了我应该使用的服务器的模拟版本,并且 gbjbaanb 似乎对 Windows 也有效。 与 *nix 一样,相对路径根据 apache 启动时的当前目录工作。 因此,对于 Windows,只需确保将当前目录的环境变量设置为您希望 apache 相对的目录即可。 对于.NET,您只需适当设置 System.IO.Directory.SetCurrentDirectory() 或 System.Environment.CurrentDirectory 即可。 我想对于 *nix,您可以在运行之前 cd 进入目录或使用 chroot。

I've quickly booted up a mock version of the server that I'm supposed to use and it seems what gbjbaanb is valid for Windows as well. As with *nix, the relative paths work based on what the current directory is when apache is launched. So for Windows, just make sure to set the environment variable for the current directory to the one you want apache to be relative of. For .NET, you just set System.IO.Directory.SetCurrentDirectory() or System.Environment.CurrentDirectory appropriately. I suppose for *nix, you would either cd into the directory before running or use chroot.

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