FastCGI + Apache:如何将url映射到特定的fastcgi二进制文件

我写了两个C ++ fastcgi应用程序(foo和foobar)。 我在Ubuntu 10.x上使用mod_fcgid运行apache 2.2(prefork)。

我想能够设置Apache以便:

HTTP:// mywebsite /一些/ PATH1参数1 =值1&参数2 =值2

将运行fastcgi应用程序foo

mywebsite /另一个/ PATH1?参数1 =值1&参数2 =值2

将运行fastcgi应用程序foobar

注意:上面的URL是故意无效的(缺less协议types),因为我不能在此问题中发布多个链接。

我如何设置Apache来实现这一目标?

最简单的方法是使用打开“虚拟”的FcgidWrapper指令。 这意味着Apache甚至不会尝试查找“真实”文件,只需调用fcgi脚本即可。

DocumentRoot /whatever <Directory /whatever/some/path1> FcgidWrapper /elsewhere/bin/foo virtual </Directory> <Directory /whatever/another/path1> FcgidWrapper /elsewhere/bin/foobar virtual </Directory> 

或者,你可以使用mod_rewrite这样的东西:

 DocumentRoot /whatever <Directory /whatever> RewriteRule /some/path1 /fcgi/foo RewriteRule /another/path1 /fcgi/foobar </Directory> <Directory /whatever/fcgi> SetHandler fcgid-script </Directory>