美文网首页
在CentOS 7.6上使用lighttpd

在CentOS 7.6上使用lighttpd

作者: 苍蝇的梦 | 来源:发表于2020-02-10 21:45 被阅读0次

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后就能正常访问了。

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,可以了。

Line Endings

相关文章

网友评论

      本文标题:在CentOS 7.6上使用lighttpd

      本文链接:https://www.haomeiwen.com/subject/ywvaxhtx.html