一、安装相关软件包
[root@web ~]# yum -y install pcre pcre-devel bzip2-devel zlib zlib-devel mysql-server php php-mysql
二、编译并安装lighttpd
[root@web ~]# tar zxf lighttpd-1.4.30.tar.gz
[root@web ~]# cd lighttpd-1.4.30
[root@web lighttpd-1.4.30]# ./configure --prefix=/usr/local/lighttpd --with-openssl --with-openssl-libs=/usr/lib
[root@web lighttpd-1.4.30]# make && make install
配置启动及配置文件目录
[root@web lighttpd-1.4.30]# cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd
[root@web lighttpd-1.4.30]# chmod +x /etc/init.d/lighttpd
[root@web lighttpd-1.4.30]# cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
[root@web lighttpd-1.4.30]# mkdir -p /etc/lighttpd
[root@web lighttpd-1.4.30]# cp -rf doc/config/* /etc/lighttpd/
[root@web lighttpd-1.4.30]# chkconfig --add lighttpd
[root@web lighttpd-1.4.30]# chkconfig lighttpd on
[root@web ~]# vim +29 /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd"
修改成:
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
[root@web ~]# mkdir -p /srv/www/htdocs
[root@web ~]# mkdir /var/log/lighttpd
[root@web ~]# touch /var/log/lighttpd/access.log
[root@web ~]# touch /var/log/lighttpd/error.log
[root@web ~]# useradd lighttpd
[root@web ~]# chown -R lighttpd:lighttpd /var/log/lighttpd/
关闭ipv6的支持
[root@web ~]# vim +93 /etc/lighttpd/lighttpd.conf
server.use-ipv6 = "enable"
修改成:
server.use-ipv6 = "disable"
将压缩缓存目录修改到/tmp下
vim /etc/lighttpd/lighttpd.conf
var.cache_dir = "/tmp/cache/lighttpd"
启动服务,查看端口监听
[root@web ~]# /etc/init.d/lighttpd start
Starting lighttpd: [ OK ]
[root@web ~]# netstat -tnlp | grep lighttpd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10601/lighttpd
三、配置fastcgi支持php
配置lighttpd modules(/etc/lighttpd/modules.conf)取消需要用到模块的注释:mod_rewrite,mod_redirect,mod_access,mod_fastcgi,mod_compress,mod_accesslog
修改后:
- server.modules = (
- "mod_access",
- "mod_redirect",
- "mod_rewrite",
- )
- include "conf.d/compress.conf"
- include "conf.d/fastcgi.conf"
配置/etc/lighttpd/conf.d/fastcgi.conf支持PHP
- fastcgi.server =(".php"=>
- ("localhost"=>
- (
- "socket"=>"/tmp/php-fastcgi.socket",
- "bin-path"=>"/usr/bin/php-cgi",
- "max-procs"=>2,
- "bin-environment"=>
- (
- "PHP_FCGI_CHILDREN"=>"84",
- "PHP_FCGI_MAX_REQUESTS"=>"1000"
- ),
- "broken-scriptfilename"=>"enable"
- )
- )
- )
测试,在/srv/www/htdocs下建立以下测试文件:
[root@web ~]# cat /srv/www/htdocs/test.php
phpinfo();
?>
浏览器打开
转载于:https://blog.51cto.com/liyaoyi/827200