Lighttpd安装及secdownload,fastcgi,proxy配置
1,下载安装lighttpd-1.4.34 lighttpd官网下载最新稳定版本 [root@localhost software]#tar -zxvf lighttpd-1.4.34.tar.gz [root@localhost software]#cd lighttpd-1.4.34 [root@localhost lighttpd-1.4.34]#./configure --prefix=/usr/local/lighttpd #安装默认模块 [root@localhost lighttpd-1.4.34]#make && make install
2,添加lighttp运行用户 [root@localhost lighttpd-1.4.34]#useradd -M -s /sbin/nologin lighttpd
3,拷贝配置文件模板 [root@localhost lighttpd-1.4.34]# cd doc/ [root@localhost doc]# ls config initscripts lighttpd.8 Makefile Makefile.am Makefile.in newstyle.css oldstyle.css outdated scripts systemd [root@localhost doc]# cp -r config /usr/local/lighttpd/ 然后删除正式安装目录下的Makefile文件 [root@localhost config]# rm -rf Makefile*
4,拷贝服务启动脚本文件并添加自启动 [root@localhost initscripts]# pwd /root/software/lighttpd-1.4.34/doc/initscripts [root@localhost initscripts]# cp rc.lighttpd.RedHat /etc/init.d/lighttpd [root@localhost initscripts]# chkconfig lighttpd on [root@localhost initscripts]# chmod u x /etc/init.d/lighttpd
5,修改启动脚本文件中的配置路径 ,如下 if [ -z "$LIGHTTPD_CONF_PATH" ]; then LIGHTTPD_CONF_PATH="/usr/local/lighttpd/config/lighttpd.conf" #定义配置文件目录 fi lighttpd="/usr/local/lighttpd/sbin/lighttpd" #定义主程序命令位置
6,修改主配置lighttpd.conf文件
var.home_dir = "/usr/local/lighttpd" #定义程序主目录
var.server_root = "/home/html" #定义web应用主目录
var.log_root = home_dir "/var/log" #定义日志目录
var.state_dir = home_dir "/var/run" #定义运行状态文件目录
var.conf_dir = home_dir "/etc" #定义配置文件目录
var.vhosts_dir = server_root "/vhosts" #定义虚拟主机配置目录
var.cache_dir = home_dir "/var/cache" #定义缓存目录
var.socket_dir = home_dir "/sockets" #定义socket文件目录
include "modules.conf" #加载系统模块配置文件
server.port = 8080 #系统监听端口
server.use-ipv6 = "disable"
server.username = "lighttpd" #运行用户身份
server.groupname = "lighttpd" #运行组身份
server.document-root = server_root #定义web应用目录
server.pid-file = state_dir "/lighttpd.pid"
server.errorlog = log_root "/error.log"
include "conf.d/access_log.conf"
include "conf.d/debug.conf"
server.event-handler = "linux-sysepoll"
server.network-backend = "linux-sendfile"
server.max-fds = 2048
server.stat-cache-engine = "simple"
server.max-connections = 1024
index-file.names = (
"index.xhtml", "index.html", "index.htm", "default.htm", "index.php"
)
url.access-deny = ( "~", ".inc" )
$HTTP["url"] =~ ".pdf$" {
server.range-requests = "disable"
}
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi" )
include "conf.d/mime.conf"
include "conf.d/dirlisting.conf"
server.follow-symlink = "enable"
server.upload-dirs = ( "/tmp" )
7,启动相应模块及其主文件配置 模块配置文件 [root@localhost etc]# cat modules.conf |grep -v ^# | grep -v ^$ server.modules = ( "mod_access", "mod_rewrite", #启用重定向 ) include "conf.d/proxy.conf" #启用代理模块 include "conf.d/secdownload.conf" #启动secdownload防盗链模块 include "conf.d/fastcgi.conf" #启用fastcgi模块
代理配置主文件 [root@localhost etc]# cat conf.d/proxy.conf |grep -v ^# | grep -v ^$ server.modules = ( "mod_proxy" )
proxy.server = ( ".php" => ( "nginx" => ( "host" => "127.0.0.1", "port" => 80 ) ), ".mp3"=> ( "nginx" => ( "host" => "127.0.0.1", "port" => 80 ) ) )
secdownload防盗链模块配置主文件 [root@localhost etc]# cat conf.d/secdownload.conf |grep -v ^# | grep -v ^$ server.modules = ( "mod_secdownload" ) secdownload.document-root = server_root "/music" secdownload.secret = "Tgn.com" secdownload.timeout = 60 secdownload.uri-prefix = "/mp3/"
PHP fastcgi配置主文件 [root@localhost etc]# cat conf.d/fastcgi.conf |grep -v ^# | grep -v ^$ server.modules = ( "mod_fastcgi" ) fastcgi.server = ( ".php" => ( "php-tcp" => ( "host" => "127.0.0.1", "port" => 9000, "check-local" => "disable", "broken-scriptfilename" => "enable", ) ), )
8,根据配置建立日志及其它目录 [root@localhost lighttpd]# mkdir -p var/log [root@localhost lighttpd]# mkdir -p var/run [root@localhost lighttpd]# mkdir -p var/cache [root@localhost lighttpd]# mkdir -p socket
9,启动测试 [root@localhost lighttpd]# service lighttpd restart