我一直在尝试在lighttpd中运行lua脚本.我正在运行gentoo,我使用lua use标志安装了lighttpd.mod_magnet.so应该是它应该的位置.当我尝试启动服务器时,我收到此错误:
2011-06-03 15:55:32: (configfile.c.912) source: /etc/lighttpd/lighttpd.conf line: 43 pos: 68 parser failed somehow near here: (
Run Code Online (Sandbox Code Playgroud)
这是我的配置文件:
###############################################################################
# Default lighttpd.conf for Gentoo.
# $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/conf/lighttpd.conf,v 1.5 2010/11/18 15:13:47 hwoarang Exp $
###############################################################################
# {{{ variables
var.basedir = "/var/www/localhost"
var.logdir = "/var/log/lighttpd"
var.statedir = "/var/lib/lighttpd"
# }}}
# {{{ modules
# At the very least, mod_access and mod_accesslog should be enabled.
# All other modules should only be loaded if necessary.
# NOTE: the order of modules is important. …Run Code Online (Sandbox Code Playgroud) 我正在使用 lighttpd 并编写了以下 cgi 脚本:
main(){
printf("Content-type: text/html\n\n");
char * pwd ="";
pwd=getenv("PWD");
printf ("The current path is: %s",pwd);
}
Run Code Online (Sandbox Code Playgroud)
结果是
The current path is: (null)
Run Code Online (Sandbox Code Playgroud)
嗯,我不明白为什么。而且我不知道如何找到执行脚本的路径。我正在寻找带有路径的 args[0],并为此使用了 pwd,但也许我应该切换到不同的东西。
更新
不工作也是
char cwd[_PC_PATH_MAX+1];
getcwd(cwd, _PC_PATH_MAX+1);
Run Code Online (Sandbox Code Playgroud)
cwd 是“”。如果我停止使用房间 1408 作为我的数据中心,我的脚本可能知道它在哪里。:P
我想重定向以以下内容开头的地址:
en.example.com/somefile.php
Run Code Online (Sandbox Code Playgroud)
至:
example.com/somefile.php?language=en
Run Code Online (Sandbox Code Playgroud)
在lighttpd中使用mod_rewrite模块.到现在为止我得到了这个:
$HTTP["host"] =~ "^en\.(.*)\.com$" {
url.rewrite-once = (
"^/(.*)"
=>
"/$1?language=en"
)
}
Run Code Online (Sandbox Code Playgroud)
但这似乎并没有起作用.该怎么做才能使这项工作?
所以我使用Light HTTPd编写了一个用C++编写的FastCGI应用程序,但是我无法使用它来检索查询字符串getenv("QUERY_STRING").如果我取出查询字符串请求(或添加一个null的检查),一切正常,但有了它,它失败了:
#include <stdlib.h>
#ifdef _WIN32
#include <process.h>
#else
#include <unistd.h>
extern char ** environ;
#endif
#include "fcgio.h"
#include "fcgi_config.h" // HAVE_IOSTREAM_WITHASSIGN_STREAMBUF
#include "redisclient.h"
Run Code Online (Sandbox Code Playgroud)
....
while (FCGX_Accept_r(&request) == 0)
{
fcgi_streambuf cin_fcgi_streambuf(request.in);
fcgi_streambuf cout_fcgi_streambuf(request.out);
fcgi_streambuf cerr_fcgi_streambuf(request.err);
Run Code Online (Sandbox Code Playgroud)
...
cout << "Content-type: text/html\r\n"
"\r\n"
"<TITLE>^_^</TITLE>\n"
"<H1>echo-cfpp</H1>\n"
"<H4>PID: " << pid << "</H4>\n"
"<H4>Request Number: " << ++count << "</H4>\n";
// If I make this conditional on getenv("QUERY_STRING") not returning null,
// then the program behaves reliably.
cout <<getenv("QUERY_STRING");
}
Run Code Online (Sandbox Code Playgroud)
我已经验证我在请求中传递了一个查询字符串,那么为什么getenv("QUERY_STRING")返回null?我 …