1、编译lighttpd
1、解压tar -xzvf lighttpd-1.4.64.tar.gz
2、进入lighttpd-1.4.64目录下,执行 ./configure --prefix=/home/nvidia/CGI/lighttpd_project(这是你自己要编译安装的目录)
但是因为没有安装prec2
安装
3、make
4、make install
5、执行以上步骤之后,lighttpd_project目录下就会生成lib sbin share三个目录
配置支持CGI
1、lighttpd_project目录下新建文件夹cgi,用于存放用C语言编写的cgi程序
2、lighttpd_project目录下新建文件夹config,将源码目录下doc/config下的 conf.d,vhosts.d,lighttpd.conf,modules.conf都拷贝过来
3、lighttpd_project目录下新建文件夹log,并创建文件access.log和error.log
4、lighttpd_project目录下新建文件夹state
5、lighttpd_project目录下新建文件夹www/htdocs/cgi-bin, 用于存放编译的cgi二进制文件
6、修改配置文件lighttpd.conf,具体修改如下所示
var.log_root = "/home/lizj/0002_linux/lighttpd/lighttpd_project/log"
var.server_root = "/home/lizj/0002_linux/lighttpd/lighttpd_project/www"
var.state_dir = "/home/lizj/0002_linux/lighttpd/lighttpd_project/state"
var.home_dir = "/home/lizj/0002_linux/lighttpd/lighttpd_project/lib"
var.conf_dir = "/home/lizj/0002_linux/lighttpd/lighttpd_project/config"
server.document-root = server_root + "/htdocs" (注意,这个是提交表单的时候,以这个为基准的相对目录)
include "../config/modules.conf"
include "../config/conf.d/access_log.conf"
include "../config/conf.d/debug.conf"
include "../config/conf.d/mime.conf"
服务器默认端口设置(因为80老是报permission denied)
server.port = 8080
关闭ipv6
server.use-ipv6 = “disable”
关闭虚拟用户
#server.username = “lighttpd”
#server.groupname = “lighttpd”
改成所有用户都可以
server.username = “nobody”
127行注释掉
#server.pid-file = state_dir + “/lighttpd.pid”
7、修改配置文件modules.conf,具体修改如下所示
server.modules = (
"mod_access",
# "mod_cgi",
"mod_alias",
# "mod_fastcgi",
"mod_compress"
# "mod_auth",
# "mod_evasive",
# "mod_redirect",
# "mod_rewrite",
# "mod_setenv",
# "mod_usertrack",
)
include "conf.d/cgi.conf" // 注意一定要增加这个,否则提交表单之后,cgi没有解析
8、修改配置文件cgi.conf,具体修改如下所示
cgi.assign = ( ".pl" => "/usr/bin/perl",
#".cgi" => "",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python" )
$HTTP["url"] =~ "^(/~[^/]+)?/cgi-bin/" {
cgi.assign = ("" => "")
}
测试验证
1、进入sbin目录下,执行./lighttpd -f …/config/lighttpd.conf
2、netstat -ltp命令查看是否已经启动