Lighttpd(LightHttpd) - 安装/配置

预备


  文章声明

   

作者:傲风([email protected])编写时间:2008年12月11日

网址:http://aofengblog.blog.163.com

SUSELinux9

lighttpd-1.4.20.tar.gz

pcre-7.8.tar.gz

zlib-1.2.3.tar.gz

安装

1、Zlib
1)安装Zlib。
./configure --prefix=/nfs10/aofeng/zlib-1.2.3 --shared
Checking for gcc...

Checkingforsharedlibrarysupport...

Buildingsharedlibrarylibz.so.1.2.3withgcc.

Checkingforunistd.h...Yes.

Checkingwhethertousevs[n]printf()ors[n]printf()...usingvs[n]printf()

Checkingforvsnprintf()instdio.h...Yes.

Checkingforreturnvalueofvsnprintf()...Yes.

Checkingforerrno.h...Yes.

Checkingformmapsupport...Yes.

make
gcc -fPIC -O3 -DUSE_MMAP   -c -o example.o example.c

gcc-fPIC-O3-DUSE_MMAP-c-oadler32.oadler32.c

gcc-fPIC-O3-DUSE_MMAP-c-ocompress.ocompress.c

gcc-fPIC-O3-DUSE_MMAP-c-ocrc32.ocrc32.c

gcc-fPIC-O3-DUSE_MMAP-c-ogzio.ogzio.c

gcc-fPIC-O3-DUSE_MMAP-c-ouncompr.ouncompr.c

gcc-fPIC-O3-DUSE_MMAP-c-odeflate.odeflate.c

gcc-fPIC-O3-DUSE_MMAP-c-otrees.otrees.c

gcc-fPIC-O3-DUSE_MMAP-c-ozutil.ozutil.c

gcc-fPIC-O3-DUSE_MMAP-c-oinflate.oinflate.c

gcc-fPIC-O3-DUSE_MMAP-c-oinfback.oinfback.c

gcc-fPIC-O3-DUSE_MMAP-c-oinftrees.oinftrees.c

gcc-fPIC-O3-DUSE_MMAP-c-oinffast.oinffast.c

gcc-shared-Wl,-soname,libz.so.1-olibz.so.1.2.3adler32.ocompress.ocrc32.ogzio.ouncompr.odeflate.otrees.ozutil.oinflate.oinfback.oinftrees.oinffast.o

rm-flibz.solibz.so.1

ln-slibz.so.1.2.3libz.so

ln-slibz.so.1.2.3libz.so.1

gcc-fPIC-O3-DUSE_MMAP-oexampleexample.o-L.libz.so.1.2.3

gcc-fPIC-O3-DUSE_MMAP-c-ominigzip.ominigzip.c

gcc-fPIC-O3-DUSE_MMAP-ominigzipminigzip.o-L.libz.so.1.2.3

make check           # 这一步也可以不执行,只是为了校验make是否成功
helloworld

zlibversion1.2.3=0x1230,compileflags=0x55

uncompress():hello,hello!

gzread():hello,hello!

gzgets()aftergzseek:hello!

inflate():hello,hello!

large_inflate():OK

afterinflateSync():hello,hello!

inflatewithdictionary:hello,hello!

***zlibtestOK***

make install
cpzlib.hzconf.h/nfs10/aofeng/zlib-1.2.3/include

chmod644/nfs10/aofeng/zlib-1.2.3/include/zlib.h/nfs10/aofeng/zlib-1.2.3/include/zconf.h

cplibz.so.1.2.3/nfs10/aofeng/zlib-1.2.3/lib

cd/nfs10/aofeng/zlib-1.2.3/lib;chmod755libz.so.1.2.3

cd/nfs10/aofeng/zlib-1.2.3/lib;iftest-flibz.so.1.2.3;then\

rm-flibz.solibz.so.1;\

ln-slibz.so.1.2.3libz.so;\

ln-slibz.so.1.2.3libz.so.1;\

(ldconfig||true)>/dev/null2>&1;\

fi

cpzlib.3/nfs10/aofeng/zlib-1.2.3/share/man/man3

chmod644/nfs10/aofeng/zlib-1.2.3/share/man/man3/zlib.3

2)查看Zlib安装后生成的文件。

首先进入Zlib安装时用--prefix指定的目录,安装后生成了三个目录:include、lib、share。

ls
includelibshare
ls -l lib
total 82

lrwxrwxrwx1aofengusers132008-12-1017:14libz.so->libz.so.1.2.3

lrwxrwxrwx1aofengusers132008-12-1017:14libz.so.1->libz.so.1.2.3

-rwxr-xr-x1aofengusers816072008-12-1017:14libz.so.1.2.3

ls -l include
total 75

-rw-r--r--1aofengusers95442008-12-1017:14zconf.h

-rw-r--r--1aofengusers661882008-12-1017:14zlib.h

3)将Zlib加入环境变量。
ZLIB_HOME=$USER_HOME/zlib-1.2.3

LD_LIBRARY_PATH=$ZLIB_HOME/lib:$LD_LIBRARY_PATH

exportLD_LIBRARY_PATH

2、Pcre

1)安装Pcre。
./configure --prefix=/nfs10/aofeng/pcre-7.8 --enable-utf8 --enable-unicode-properties
…… ……

pcre-7.8configurationsummary:

Installprefix..................:/nfs10/nieyong/pcre-7.8

Cpreprocessor..................:gcc-E

Ccompiler......................:gcc

C++preprocessor................:g++-E

C++compiler....................:g++

Linker..........................:/usr/i586-suse-linux/bin/ld

Cpreprocessorflags............:

Ccompilerflags................:-O2

C++compilerflags..............:-O2

Linkerflags....................:

Extralibraries.................:

BuildC++library...............:yes

EnableUTF-8support............:yes

Unicodeproperties..............:yes

Newlinechar/sequence...........:lf

\RmatchesonlyANYCRLF.........:no

EBCDICcoding...................:no

Rebuildchartables.............:no

Usestackrecursion.............:yes

POSIXmemthreshold.............:10

Internallinksize..............:2

Matchlimit.....................:10000000

Matchlimitrecursion...........:MATCH_LIMIT

Buildsharedlibs...............:yes

Buildstaticlibs...............:yes

Linkpcregrepwithlibz.........:no

Linkpcregrepwithlibbz2.......:no

Linkpcretestwithlibreadline..:no

make
…… ……
make install
…… ……

2)查看Pcre安装的文件。

首先进入Pcre安装时用--prefix指定的目录,安装后生成了四个目录:bin、include、lib、share。

ls
binincludelibshare
ls -l bin
total79

-rwxr-xr-x1aofengusers12602008-12-1017:32pcre-config

-rwxr-xr-x1aofengusers318992008-12-1017:32pcregrep

-rwxr-xr-x1aofengusers458752008-12-1017:32pcretest

ls -l include
total65

-rw-r--r--1aofengusers67832008-12-1017:32pcrecpparg.h

-rw-r--r--1aofengusers262532008-12-1017:32pcrecpp.h

-rw-r--r--1aofengusers124812008-12-1017:32pcre.h

-rw-r--r--1aofengusers50292008-12-1017:32pcreposix.h

-rw-r--r--1aofengusers66002008-12-1017:32pcre_scanner.h

-rw-r--r--1aofengusers62162008-12-1017:32pcre_stringpiece.h

ls -l lib
total555

-rw-r--r--1aofengusers2217022008-12-1017:32libpcre.a

-rw-r--r--1aofengusers354302008-12-1017:32libpcrecpp.a

-rwxr-xr-x1aofengusers8872008-12-1017:32libpcrecpp.la

lrwxrwxrwx1aofengusers192008-12-1017:32libpcrecpp.so->libpcrecpp.so.0.0.0

lrwxrwxrwx1aofengusers192008-12-1017:32libpcrecpp.so.0->libpcrecpp.so.0.0.0

-rwxr-xr-x1aofengusers413442008-12-1017:32libpcrecpp.so.0.0.0

-rwxr-xr-x1aofengusers8052008-12-1017:32libpcre.la

-rw-r--r--1aofengusers35182008-12-1017:32libpcreposix.a

-rwxr-xr-x1aofengusers8792008-12-1017:32libpcreposix.la

lrwxrwxrwx1aofengusers212008-12-1017:32libpcreposix.so->libpcreposix.so.0.0.0

lrwxrwxrwx1aofengusers212008-12-1017:32libpcreposix.so.0->libpcreposix.so.0.0.0

-rwxr-xr-x1aofengusers90872008-12-1017:32libpcreposix.so.0.0.0

lrwxrwxrwx1aofengusers162008-12-1017:32libpcre.so->libpcre.so.0.0.1

lrwxrwxrwx1aofengusers162008-12-1017:32libpcre.so.0->libpcre.so.0.0.1

-rwxr-xr-x1aofengusers2150602008-12-1017:32libpcre.so.0.0.1

drwxr-xr-x2aofengusers5122008-12-1017:32pkgconfig

3)将pcre加入环境变量。

PCRE_HOME=$USER_HOME/pcre-7.8

PATH=$PCRE_HOME/bin:$PATH

exportPATH

LD_LIBRARY_PATH=$PCRE_HOME/lib:$LD_LIBRARY_PATH

exportLD_LIBRARY_PATH

3、Lighttpd。

1)安装Lighttpd。
./configure --prefix=/nfs10/nieyong/lighttpd-1.4.20
…………

checkingforperlregularexpressionssupport...yes

checkingforpcre-config.../nfs10/nieyong/pcre-7.8/bin/pcre-config

checkingforpcre_compilein-lpcre...yes

checkingpcre.husability...yes

checkingpcre.hpresence...yes

checkingforpcre.h...yes

checkingforzlibsupport...yes

checkingfordeflatein-lz...yes

checkingzlib.husability...yes

checkingzlib.hpresence...yes

checkingforzlib.h...yes

…………

configure:creating./config.status

config.status:creatingMakefile

config.status:creatingsrc/Makefile

config.status:creatingdoc/Makefile

config.status:creatingtests/Makefile

config.status:creatingtests/docroot/Makefile

config.status:creatingtests/docroot/123/Makefile

config.status:creatingtests/docroot/www/Makefile

config.status:creatingtests/docroot/www/go/Makefile

config.status:creatingtests/docroot/www/indexfile/Makefile

config.status:creatingtests/docroot/www/expire/Makefile

config.status:creatingdistribute.sh

config.status:creatingcygwin/Makefile

config.status:creatingcygwin/lighttpd.README

config.status:creatingopenwrt/Makefile

config.status:creatingopenwrt/control

config.status:creatingopenwrt/lighttpd.mk

config.status:creatingconfig.h

config.status:config.hisunchanged

config.status:executingdepfilescommands

Plugins:

enabled:

mod_access

mod_accesslog

mod_alias

mod_auth

mod_cgi

mod_compress

mod_dirlisting

mod_evhost

mod_expire

mod_extforward

mod_fastcgi

mod_flv_streaming

mod_indexfiles

mod_proxy

mod_redirect

mod_rewrite

mod_rrdtool

mod_scgi

mod_secdownload

mod_setenv

mod_simple_vhost

mod_ssi

mod_staticfile

mod_status

mod_trigger_b4_dl

mod_userdir

mod_usertrack

mod_webdav

disabled:

mod_cml

mod_magnet

mod_mysql_vhost

Features:

enabled:

auth-crypt

compress-bzip2

compress-deflate

compress-gzip

large-files

network-ipv6

regex-conditionals

disabled:

auth-ldap

network-openssl

stat-cache-fam

storage-gdbm

storage-memcache

webdav-locks

webdav-properties

注意:如果没有将pcre的bin目录加入环境变量PATH中,在执行这个步骤时将报错:

checkingforpcre-config...no

configure:error:pcre-confignotfound,installthepcre-develpackageorbuildwith--without-pcre

并且中断安装。

make
…………
make install
…………

2)查看Lighttpd安装的文件。

首先进入Lighttpd安装时用--prefix指定的目录,安装后生成了四个目录:bin、lib、sbin、share。

ls
binlibsbinshare
ls -l bin
total25

-rwxr-xr-x1aofengusers253542008-12-1110:25spawn-fcgi

ls -l lib
total1370

-rwxr-xr-x1aofengusers8122008-12-1110:25mod_access.la

-rwxr-xr-x1aofengusers8302008-12-1110:25mod_accesslog.la

-rwxr-xr-x1aofengusers414032008-12-1110:25mod_accesslog.so

-rwxr-xr-x1aofengusers280202008-12-1110:25mod_access.so

-rwxr-xr-x1aofengusers8062008-12-1110:25mod_alias.la

-rwxr-xr-x1aofengusers293712008-12-1110:25mod_alias.so

-rwxr-xr-x1aofengusers8082008-12-1110:25mod_auth.la

-rwxr-xr-x1aofengusers713032008-12-1110:25mod_auth.so

-rwxr-xr-x1aofengusers7942008-12-1110:25mod_cgi.la

-rwxr-xr-x1aofengusers519682008-12-1110:25mod_cgi.so

-rwxr-xr-x1aofengusers7982008-12-1110:25mod_cml.la

-rwxr-xr-x1aofengusers427732008-12-1110:25mod_cml.so

-rwxr-xr-x1aofengusers8472008-12-1110:25mod_compress.la

-rwxr-xr-x1aofengusers452322008-12-1110:25mod_compress.so

-rwxr-xr-x1aofengusers9052008-12-1110:25mod_dirlisting.la

-rwxr-xr-x1aofengusers493302008-12-1110:25mod_dirlisting.so

-rwxr-xr-x1aofengusers8182008-12-1110:24mod_evasive.la

-rwxr-xr-x1aofengusers272252008-12-1110:24mod_evasive.so

-rwxr-xr-x1aofengusers8122008-12-1110:25mod_evhost.la

-rwxr-xr-x1aofengusers318032008-12-1110:25mod_evhost.so

-rwxr-xr-x1aofengusers8122008-12-1110:25mod_expire.la

-rwxr-xr-x1aofengusers332302008-12-1110:25mod_expire.so

-rwxr-xr-x1aofengusers8362008-12-1110:25mod_extforward.la

-rwxr-xr-x1aofengusers359902008-12-1110:25mod_extforward.so

-rwxr-xr-x1aofengusers8182008-12-1110:25mod_fastcgi.la

-rwxr-xr-x1aofengusers988472008-12-1110:25mod_fastcgi.so

-rwxr-xr-x1aofengusers8542008-12-1110:24mod_flv_streaming.la

-rwxr-xr-x1aofengusers320192008-12-1110:24mod_flv_streaming.so

-rwxr-xr-x1aofengusers8302008-12-1110:25mod_indexfile.la

-rwxr-xr-x1aofengusers295992008-12-1110:25mod_indexfile.so

-rwxr-xr-x1aofengusers8162008-12-1110:25mod_magnet.la

-rwxr-xr-x1aofengusers221862008-12-1110:25mod_magnet.so

-rwxr-xr-x1aofengusers8422008-12-1110:25mod_mysql_vhost.la

-rwxr-xr-x1aofengusers231122008-12-1110:25mod_mysql_vhost.so

-rwxr-xr-x1aofengusers8062008-12-1110:25mod_proxy.la

-rwxr-xr-x1aofengusers502362008-12-1110:25mod_proxy.so

-rwxr-xr-x1aofengusers8932008-12-1110:25mod_redirect.la

-rwxr-xr-x1aofengusers315202008-12-1110:25mod_redirect.so

-rwxr-xr-x1aofengusers8872008-12-1110:25mod_rewrite.la

-rwxr-xr-x1aofengusers356542008-12-1110:25mod_rewrite.so

-rwxr-xr-x1aofengusers8182008-12-1110:25mod_rrdtool.la

-rwxr-xr-x1aofengusers360122008-12-1110:25mod_rrdtool.so

-rwxr-xr-x1aofengusers8002008-12-1110:25mod_scgi.la

-rwxr-xr-x1aofengusers773612008-12-1110:25mod_scgi.so

-rwxr-xr-x1aofengusers8422008-12-1110:25mod_secdownload.la

-rwxr-xr-x1aofengusers306912008-12-1110:25mod_secdownload.so

-rwxr-xr-x1aofengusers8122008-12-1110:25mod_setenv.la

-rwxr-xr-x1aofengusers293862008-12-1110:25mod_setenv.so

-rwxr-xr-x1aofengusers8482008-12-1110:25mod_simple_vhost.la

-rwxr-xr-x1aofengusers307892008-12-1110:25mod_simple_vhost.so

-rwxr-xr-x1aofengusers8632008-12-1110:25mod_ssi.la

-rwxr-xr-x1aofengusers852992008-12-1110:25mod_ssi.so

-rwxr-xr-x1aofengusers8362008-12-1110:25mod_staticfile.la

-rwxr-xr-x1aofengusers383472008-12-1110:25mod_staticfile.so

-rwxr-xr-x1aofengusers8122008-12-1110:25mod_status.la

-rwxr-xr-x1aofengusers460272008-12-1110:25mod_status.so

-rwxr-xr-x1aofengusers9232008-12-1110:25mod_trigger_b4_dl.la

-rwxr-xr-x1aofengusers298752008-12-1110:25mod_trigger_b4_dl.so

-rwxr-xr-x1aofengusers8182008-12-1110:25mod_userdir.la

-rwxr-xr-x1aofengusers320062008-12-1110:25mod_userdir.so

-rwxr-xr-x1aofengusers8302008-12-1110:25mod_usertrack.la

-rwxr-xr-x1aofengusers313382008-12-1110:25mod_usertrack.so

-rwxr-xr-x1aofengusers8122008-12-1110:25mod_webdav.la

-rwxr-xr-x1aofengusers601802008-12-1110:25mod_webdav.so

ls -l sbin
total591

-rwxr-xr-x1aofengusers5739172008-12-1110:25lighttpd

-rwxr-xr-x1aofengusers146572008-12-1110:25lighttpd-angel

验证
1)显示Lighttpd的版本信息。

进入sbin目录。

./lighttpd -v
lighttpd-1.4.20-alightandfastwebserver

Build-Date:Dec11200810:18:59

2)显示编译特性。

./lighttpd -V
lighttpd-1.4.20-alightandfastwebserver

Build-Date:Dec11200810:18:59

EventHandlers:

+select(generic)

+poll(Unix)

+rt-signals(Linux2.4+)

+epoll(Linux2.6)

-/dev/poll(Solaris)

-kqueue(FreeBSD)

Networkhandler:

+sendfile

Features:

+IPv6support

+zlibsupport

+bzip2support

+cryptsupport

-SSLSupport

+PCREsupport

-mySQLsupport

-LDAPsupport

-memcachedsupport

-FAMsupport

-LUAsupport

-xmlsupport

-SQLitesupport

-GDBMsupport

3)拷贝配置文件。

为了便于管理,在lighttpd的安装目录下新建一个目录:config,专门用于存放配置文件。

将配置文件lighttpd.conf从lighttpd的安装源文件的doc目录下复制到config目录下。

4)建立应用根目录。

仿JAVA的WEB容器,在lighttpd的安装目录下建立一个目录:webapps,作为lighttpd的默认应用根目录。

修改配置文件:

server.document-root="/srv/www/htdocs/"

将“=”后面的值修改成实际的路径,这里是$LIGHTTPD_HOME/webapps。

5)建立日志目录。

在lighttpd的安装目录下建立一个目录:logs,作为存放lighttpd存放日志的目录。

修改配置文件:

server.errorlog="/var/log/lighttpd/error.log"

accesslog.filename="/var/log/lighttpd/access.log"

6)检查Lighttpd的配置文件。

./lighttpd -t -f /nfs10/aofeng/lighttpd-1.4.20/config/lighttpd.conf 
SyntaxOK

7)启动Lighttpd。

./lighttpd -f /nfs10/nieyong/lighttpd-1.4.20/config/lighttpd.conf

8)打开浏览器,输入URL,界面如下(这是我自定义的一个主页):

参考资料1、http://redmine.lighttpd.net/wiki/lighttpd/TutorialInstallation

相关推荐