lighttpd+PHP安装

lighttpd版本:1.4.32

php版本:5.4.11   2013.2.3第一次

php版本:5.4.12   2013.3.14第二次修改

 

1.lighttpd官网地址

http://www.lighttpd.net

 

2.下载安装lighttpd

#wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.32.tar.gz

# tar -zxvf lighttpd-1.4.32.tar.gz

#cd ./lighttpd-1.4.32

#./configure --prefix=/usr/local/lighttpd

#make && make install

 

3.配置lighttpd

官方文档:http://redmine.lighttpd.net/projects/lighttpd/wiki/InstallFromSource

如果不是centos

#cp doc/initscripts/rc.lighttpd  /etc/init.d/lighttpd

如果是centos
#cp doc/initscripts/rc.lighttpd.redhat   /etc/init.d/lighttpd

修改/etc/init.d/下的lighttpd文件

修改

prog="lighttpd"
lighttpd="/usr/sbin/lighttpd"


prog="lighttpd"
lighttpd="/usr//local/lighttpd/sbin/lighttpd"


# chmod a+rx /etc/init.d/lighttpd

#cp doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
#mkdir /etc/lighttpd

#cp -R doc/config/conf.d/ doc/config/*.conf  doc/config/vhosts.d/ /etc/lighttpd/

 



创建用户

# useraddlighttpd

 

创建网站目录

# mkdir  /usr/www

修改配置文件

#vim /etc/lighttpd/lighttpd.conf

var.server_root 改为   = "/usr/www"

server.document-root = server_root + "/htdocs"    改为  server.document-root = server_root + "/htdocs"

server.use-ipv6 = "enable"改为"disable"


#cd /var/log/

# mkdir  lighttpd

#chown lighttpd  /var/log/lighttpd


lighttpd常用操作

启动

# /etc/init.d/lighttpd start    

停止
# /etc/init.d/lighttpd stop     

重启

# /etc/init.d/lighttpd restart 


 

如果启动时有如下错误:
2011-09-08 20:47:57: (network.c.239) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes
将配置文件/etc/lighttpd/lighttpd.conf中的server.use-ipv6 设为 "disable"

 

如果报错:

opening errorlog '/var/log/lighttpd/error.log' failed: No such file or directory

#cd /var/log/

#mkdir  lighttpd

如果报错:

正在启动 lighttpd:2013-02-03 23:09:16: (log.c.118) opening errorlog '/var/log/lighttpd/error.log' failed: Permission denied

 

vi /etc/lighttpd/lighttpd.conf 看是那个帐户运行的,比如是lighttpd

#chown lighttpd  /var/log/lighttpd   就解决了

 

4.lighttpd绑定php的fastcgi

安装php的fastcgi参考:http://blog.csdn.net/unix21/article/details/8544922

官方文档:http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_PerformanceFastCGI

修改配置文件

# vim /etc/lighttpd/lighttpd.conf
server.modules += ( "mod_fastcgi" )
fastcgi.server = ( ".php" =>
  (( "socket" => "/tmp/php-fastcgi.socket",
    "bin-path" => "/usr/local/php/bin/php-cgi",
     "min-procs" => 1,
     "max-procs" => 1,
     "max-load-per-proc" => 4,
     "bin-environment" => (
     "PHP_FCGI_CHILDREN" => "2",
        "PHP_FCGI_MAX_REQUESTS" => "10000" ),
      "bin-copy-environment" => (
        "PATH", "SHELL", "USER" ),
      "broken-scriptfilename" => "enable",
     "idle-timeout" => 20
  ))
)

 

安装成功以后重启lighttpd


 

PHP_FCGI_CHILDREN是fastcgi所起的进程数,假设修改为20,查看系统进程数

 

性能测试

# ab -n 10000 -c 1000 http://192.168.20.210/index.php

 

 6.各种奇怪的问题参考:

http://blog.csdn.net/wangxuefeng_yctc/article/details/5652654

http://redmine.lighttpd.net/projects/lighttpd/wiki

http://blog.sina.com.cn/s/blog_613904cc0100xnlh.html

http://www.weithenn.org/cgi-bin/wiki.pl?LigHttpd-%E8%BC%95%E9%87%8F%E7%B4%9A_Web_Server

https://wiki.freebsdchina.org/howto/n/php_fastcgi_lighttpd

你可能感兴趣的:(Linux/Unix)