2020-02-10 遇到的一点小问题
最近开始使用CentOS 7.6
,继续之前在ArchLinux
上使用的lighttpd
。
yum install lighttpd
之前在ArchLinux
安装lighttpd
后,配置表只有这一些:
# This is a minimal example config
# See /usr/share/doc/lighttpd
# and http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
server.port = 80
#server.username = "http"
#server.groupname = "http"
server.document-root = "/srv/http"
server.errorlog = "/var/log/lighttpd/error.log"
dir-listing.activate = "enable"
index-file.names = ( "index.html" )
mimetype.assign = (
".html" => "text/html",
".txt" => "text/plain",
".css" => "text/css",
".js" => "application/x-javascript",
".jpg" => "image/jpeg",x
".jpeg" => "image/jpeg",
".gif" => "image/gif",
".png" => "image/png",
"" => "application/octet-stream"
)
server.modules = ("mod_cgi")
cgi.assign = (".cgi" => "")
这次在CentOS
上,要改的比较多。首先修改配置文件/etc/lighttpd/lighttpd.conf
:
将原来的server.use-ipv6 = "enable"
改成server.use-ipv6 = "disable"
,再执行systemctl start lighttpd
后就能正常访问了。
主要是通过
.cgi
文件来交互,所以还需要修改文件/etc/lighttpd/modules.conf
:将
#include "conf.d/cgi.conf"
前面的#号去掉,改成include "conf.d/cgi.conf"
。然后就是修改文件
/etc/lighttpd/conf.d/cgi.conf
。文件里面原本定义了几个指定后缀文件的执行程序
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl",
".rb" => "/usr/bin/ruby",
".erb" => "/usr/bin/eruby",
".py" => "/usr/bin/python" )
因为用不到,所以这个文件只保留了两句。
server.modules += ( "mod_cgi" )
cgi.assign = (".cgi" => "")
在/var/www/lighttpd/
建了个wannoo.cgi
,执行systemctl restart lighttpd
后,试了一下,没想到一直返回500 Internal Server Error
。把权限改成777,还是500 Internal Server Error
。
找了半天原因,没想到最后竟然是Line Endings没设置好。改成Unix,可以了。
网友评论