安装 lighttpd

yum -y install epel-release
yum search lighttpd


yum install lighttpd
systemctl start lighttpd
systemctl enable lighttpd

lighttpd -v

配置 lighttpd

server.port                 = 880

/modules.conf
取消需要用到模块的注释,
mod_rewrite,
mod_access,
mod_fastcgi,
mod_simple_vhost,
mod_cgi,
mod_compress,
mod_accesslog
#指定相应的目录
server.document-root = "/www/phc/html/"
server.errorlog = "/usr/local/lighttpd/logs/error.log"
accesslog.filename = "|/usr/sbin/cronolog /usr/local/lighttpd/logs/%Y/%m/%d/accesslog.log"
用什么权限来运行lighttpd
server.username             = "nobody"
server.groupname            = "nobody"
#静态文件压缩
compress.cache-dir          = "/usr/local/lighttpd/compress/"
compress.filetype           = ("text/plain", "text/html","text/javascript","text/css")
优化最大连接数
默认是1024
server.max-fds=2048,大流量网站推荐2048.
server.stat-cache-engine = "fam" 缓存
#keep-alive
server.max-keep-alive-requests = 128
server.max-keep-alive-idle = 30
server.max-keep-alive-requests = 0  keep-alive接受的最大请求数,0为禁止

server.network-backend = “linux-sendfile”  lighttpd 大量使用了 sendfile() 这样一个高效的系统调用.根据平台,可以设置不同的参数. 
server.network-backend = “linux-sendfile”(linux)
freebsd: freebsd-sendfile
unix: writev

server.event-handler = “linux-sysepoll” 事件处理,Linux环境下epoll系统调用可提高吞吐量
#server.max-worker = 10 # 如果你的系统资源没跑满,可考虑调高 lighttpd进程数
server.max-fds = 4096 # 默认的,应该够用了,可根据实际情况调整
server.max-connections = 4096 # 默认等于 server.max-fds

安装 php-fpm

yum -y install php php-pdo php-gd php-mbstring...
yum -y install php-fpm lighttpd-fastcgi

配置 php-fpm lighttpd-fastcgi

  • /etc/php-fpm.d/www.conf
user=lightttpd
group=lighttpd
;listen = /var/run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000

systemctl start php-fpm
systemctl enable php-fpm
  • 配置 fastcgi
1. /etc/php.ini
 cgi.fix_pathinfo=1 取消注释

2. /etc/lighttpd/modules.conf
 conf.d/fastcgi.conf 取消注释

3. /etc/lighttpd/conf.d/fastcgi.conf 
现在,在文件底部添加以下容器并保存。
fastcgi.server += ( ".php" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable"
))
)


systemctl restart lighttpd