Lighttpd是一个德国人领导的开源软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的web server环境。
具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点。
lighttpd是众多轻量级的web server中较为优秀的一个。支持FastCGI, CGI, Auth, 输出压缩(output compress), URL重写, Alias等重要功能,而Apache之所以流行,很大程度也是因为功能丰富,在lighttpd上很多功能都有相应的实现了,这点对于apache的用户是非常重要的,因为迁移到lighttpd就必须面对这些问题。
性能
根据简单性能对比,Nginx的性能比lighttpd略好。原因可能有以下几方面:
1. Lighttpd启动了几个辅助线程,有加锁竞争行为,这样会使性能有所降低(线程个数是可配的,这里还有优化的余地);nginx完全不涉及线程,不加锁。
2. Lighttpd有动态so,nginx全静态编译,动态库执行效率比静态慢大约5%~10%左右。
3. Nginx在细节优化上可能做得更好一些。例如nginx的epoll是ET(边缘触发)的,而lighttpd的epoll是LT(水平触发)的。
nginx的性能要好一些,不过对大多数应用来说,lighttpd的性能指标已够用了,一个系统主要的瓶颈往往是在后端。由于lighttpd具有动态模块的加载能力,适合非常需要灵活配置的场合。
总体而言,nginx和lighttpd都是非常好的web server选择。
yum安装 lighttpd、mysql、php
yum安装mysql
yum install mysql mysql-server
mysqladmin -u root password 123123
设置开机启动并启动MySQL
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
可以下载 RPMforge软件库,也可以用epel源
centos 5
wget http://rfyiamcool.googlecode.com/files/epel-release-5-4.noarch.rpm
centos 6
wget http://rfyiamcool.googlecode.com/files/epel-release-6-7.noarch.rpm
rpm -ivh epel*
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum install lighttpd
yum install lighttpd-fastcgi php-cli
/etc/init.d/lighttpd start
chkconfig --levels 235 lighttpd on
修改配置
|
上述命令已经同时安装好了php的MySQL、GD图形库、IMAP、ODBC、Pear、xml等支持组件。
重启Lighttpd并刷新 http://IP/test.php 页面,即可找到MySQL模块的支持。
至此,yun安装 Lighttpd+PHP+MySQL+GD全套组件安装配置完毕。
yum安装 nginx、mysql、php
#!/bin/bash
read -p "mysql root mima" mima
rpm -qa|grep httpd
rpm -e httpd
rpm -qa|grep mysql
rpm -e mysql
yum -y remove httpd*
yum -y remove mysql-server mysql
yum -y remove httpd
if cat /etc/redhat-release | grep '6..' ;then
rpm -ivh http://rfyiamcool.googlecode.com/files/epel-release-6-7.noarch.rpm
else
rpm -ivh http://rfyiamcool.googlecode.com/files/epel-release-5-4.noarch.rpm
fi
yum -y install yum-fastestmirror
yum clean all
yum install -y ntp
ntpdate -d cn.pool.ntp.org
yum install mysql mysql-server
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum install php php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy
yum install mysql mysql-server
yum install nginx pcre pcre-devel
service nginx start
service php-fpm start
/etc/init.d/mysqld start
chkconfig --levels 235 php-fpm on
chkconfig --levels 235 nginx on
chkconfig --levels 235 mysqld on
mysqladmin -u root password "$mima"
要是不想yum,需要编译安装的话,用下面的方法~~~~~~~~~~~~
[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
server.modules = (
"mod_access",
"mod_redirect",
"mod_rewrite",
)
include "conf.d/compress.conf"
include "conf.d/fastcgi.conf"
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"
)
)
)