Lighttpd的安装配置(web服务器软件)-服务器应用
作者: 出处: 更新时间:2007-10-25 责任编辑:
 
 

Lighttpd 的安装配置(web服务器软件)<Script type="text/javascript"><--google_ad_client = "pub-6912338070246884";google_alternate_color = "FFFFFF";google_ad_width = 468;google_ad_height = 60;google_ad_format = "468x60_as";google_ad_type = "text";//2007-06-15: www.techyou.cngoogle_ad_channel = "5642791638";google_color_border = "FFFFFF";google_color_bg = "FFFFFF";google_color_link = "000000";google_color_text = "000000";google_color_url = "008000";//--></Script><Script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></Script>
lighttpd(http://lighttpd.net/)和apache一样是开源的,与apache相比,虽然功能不及apache完善,稳定性也不如apache,但是,不管是服务静态页面,还是服务动态内容(CGI,PHP),它都比apache快,用于ad banner之类的WEB服务器是最恰当不过了。

本文从应用的角度,说明如何安装、配置lighttpd。

(1) 安装

可从http://lighttpd.net/download/下载最新的源码(.tar.gz)或者rpm包。如果下载的是.tar.gz文件,则和GNU的其他软件一样,先./configure一下,然后 make && make install就搞定了。但是如果你想定制一些功能,就得好好看看解压后README, INSTALL以及./configure --help的输出结果了。这里仅仅说一下如何从源码安装,其他安装方式可参考 http://trac.lighttpd.net/trac/wiki/TutorialInstallation。

$ gzip -cd lighttpd-1.4.9.tar.gz | tar xf -
...
$ cd lighttpd-1.4.9
$ ./configure --help
`configure' configures lighttpd 1.4.9 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
...

Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
...

Program names:
...

System types:
...

Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--enable-static[=PKGS]
build static libraries [default=no]
--enable-shared[=PKGS]
build shared libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-lfs Turn on Large File System (default)
--disable-ipv6 disable IPv6 support

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-pic try to use only PIC/non-PIC objects [default=use
both]
--with-tags[=TAGS]
include additional configurations [automatic]
--with-mysql[=PATH]
Include MySQL support. PATH is the path to
'mysql_config'
--with-ldap enable LDAP support
--with-attr enable extended attribute support
--with-valgrind enable internal support for valgrind
--with-openssl[=DIR]
Include openssl support (default no)
--with-openssl-includes=DIR
OpenSSL includes
--with-openssl-libs=DIR OpenSSL libraries
--with-kerberos5 use Kerberos5 support with OpenSSL
--with-pcre Enable pcre support (default yes)
--with-bzip2 Enable bzip2 support for mod_compress
--with-fam fam/gamin for reducing number of stat() calls
--with-webdav-props properties in mod_webdav
--with-gdbm gdbm storage for mod_trigger_b4_dl
--with-memcache memcached storage for mod_trigger_b4_dl
--with-lua lua engine for mod_cml

Some influential environment variables:
...
如上所述,可通过--prefix指定安装路径,默认安装在/usr/local下。可以指定启用哪些特征(插件),禁用哪些特征(插件)。假定我们要把lighttpd安装到/usr/local/lighttpd-1.4.9下面。

$ ./configure --prefix=/usr/local/lighttpd-1.4.9
$ make
$ make install
$ cp doc/lighttpd.conf /usr/local/lighttpd-1.4.9/ # 拷贝配置文件
$ cd /usr/local/lighttpd-1.4.9
$ vi lighttpd.conf # 修改配置文件
配置文件很直观明了,一般只要把server.document-root、server.errorlog、accesslog.filename改成你的实际目录和文件名字就可以了。

$ sbin/lighttpd -f lighttpd.conf # 启动lighttpd服务
$ ps aux | grep lighttpd
www 15403 0.0 0.9 2860 1148 ? S 00:15 0:00 sbin/lighttpd -f
这就完成了从安装到启动的整个过程,很简单吧。从最后一行的输出可以看出,lighttpd是单进程服务的,这和apache不一样(也许是它的稳定性不如apache的一个原因)。

(2) 整合php和fastcgi

以php-4.3.11为例,编译PHP的时候,不能指定 --with-apxs选项,编译命令行大致如下:

$ ./configure ... --enable-force-cgi-redirect --enable-fastcgi
$ make
$ sapi/cgi/php -v
PHP 4.3.11 (cgi-fcgi) (built: Jan 30 2006 00:12:34)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
make完了后,会在sapi/cli目录生成命令行下的php程序,sapi/cgi下生成fastcgi下的php程序。如果执行sapi/cgi下的php显示版本号,你会发现有 cgi-fcgi的说明,这就表明你成功了。

$ mkdir /usr/local/lighttpd-1.4.9/fcgi
$ cp sapi/cgi/php /usr/local/lighttpd-1.4.9/fcgi/
$ vi /usr/local/lighttpd-1.4.9/lighttpd.conf
我们建立一个子目录fcgi用来保存所有的fast-cgi程序,然后把php拷贝到该目录下。编辑lighttpd.conf,如下所示:

...
server.modules = (
...
"mod_fastcgi",
...)
...
fastcgi.server = (".php" =>
( "127.0.0.1" =>
(
"socket" => "/tmp/fcgi_php.sock",
"bin-path" => "/usr/local/lighttpd-1.4.9/fcgi/php"
)
)
)
重新启动lighttpd就可以了。Lighttpd和fastcgi通信有两种方式:通过Unix socket通信,如以上PHP的启动;通过TCP/IP socket通信。Lighttpd支持基于fastcgi的负载均衡,不过我没尝试过。

关于fastcgi的协议规范,请参考http://www.fastcgi.com/,以下是我自己写的一个fastcgi的配置样例:

fastcgi.server = ( "/fastcgi/adsim" =>
( "127.0.0.1" =>
(
"host" => "127.0.0.1",
"port" => 4000,
"bin-path" => "/usr/local/lighttpd-1.4.9/fcgi/adsim",
"check-local" => "disable"
)
)
check-local必须设置为disable,否则因为找不到/fastcgi/adsim会导致请求失败。

 
     
 
 
继续>>下一页
[第1页][第2页][第3页][下一页]
 
内容导航  
第1页Lighttpd的安装配置(w.. 第2页Lighttpd的安装配置(w..
第3页lighttpd
上一篇 : 如何检测和重启Apache和.. 下一篇Linux系统下Lighttpd的安..
 
  您要为所发表的言论的后果负责,请各位遵纪守法并注意文明用语
标题:  

[ 关于本站 ] [ 广告服务 ] [ 商务合作 ] [ 联系我们 ] [ 合作伙伴 ] [ 法律顾问 ] [ 网站地图 ]
千橡公司 京ICP证041489号 Copyright (c) 1997-2007 All Right Reserved.