共计 4238 个字符,预计需要花费 11 分钟才能阅读完成。
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
Lighttpd 的详细介绍 :请点这里
Lighttpd 的下载地址:请点这里
相关阅读:
CentOS 5.6 下搭建 Lighttpd http://www.linuxidc.com/Linux/2012-08/68557.htm
Cacti 监控 Lighttpd http://www.linuxidc.com/Linux/2012-01/51863.htm
Ubuntu 手动编译安装 Lighttpd 配置运行 PHP http://www.linuxidc.com/Linux/2011-12/48808.htm
移植 Lighttpd Web 服务器到 ARM Linux 系统 http://www.linuxidc.com/Linux/2011-09/43619.htm
Ubuntu 下搭建 Lighttpd+PHP+MySQL 环境 http://www.linuxidc.com/Linux/2011-07/38675.htm
在 CentOS 5.6 上安装 Lighttpd + PHP5 + MySQL http://www.linuxidc.com/Linux/2011-07/38341.htm
Lighttpd 对视频文件压缩文件做防盗链 http://www.linuxidc.com/Linux/2013-10/92039.htm