仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 415|回复: 8
打印 上一主题 下一主题

[CentOS(社区)] CentOS教程之Lighttpd 的装置设置装备摆设,参加SSL拜访

[复制链接]
海妖 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:45:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!lighttpd(http://lighttpd.net/)和apache一样是开源的,与apache比拟,固然功效不及apache完美,稳固性也不如apache,然则,不论是办事静态页面,照样办事静态内容(CGI,PHP),它都比apache快,用于adbanner之类的WEB办事器是最适当不外了。
本文从运用的角度,解释若何装置、设置装备摆设lighttpd。
(1)装置
可从http://lighttpd.net/download/下载最新的源码(.tar.gz)或许rpm包。假如下载的是.tar.gz文件,则和GNU的其他软件一样,先./configure一下,然后make&&makeinstall就弄定了。然则假如你想定制一些功效,就得好悦目看解压后README,INSTALL和./configureChelp的输入成果了。这里仅仅说一下若何从源码装置,其他装置方法可参考http://trac.lighttpd.net/trac/wiki/TutorialInstallation。
  1. $gzip-cdlighttpd-1.4.9.tar.gz|tarxf-...$cdlighttpd-1.4.9$./configure--help`configureconfigureslighttpd1.4.9toadapttomanykindsofsystems.Usage:./configure[OPTION]...[VAR=VALUE]...Toassignenvironmentvariables(e.g.,CC,CFLAGS...),specifythemasVAR=VALUE.Seebelowfordescriptionsofsomeoftheusefulvariables.Defaultsfortheoptionsarespecifiedinbrackets.Configuration:...Installationdirectories:--prefix=PREFIXinstallarchitecture-independentfilesinPREFIX[/usr/local]--exec-prefix=EPREFIXinstallarchitecture-dependentfilesinEPREFIX[PREFIX]Bydefault,`makeinstallwillinstallallthefilesin`/usr/local/bin,`/usr/local/libetc.Youcanspecifyaninstallationprefixotherthan`/usr/localusing`--prefix,forinstance`--prefix=$HOME.Forbettercontrol,usetheoptionsbelow.Finetuningoftheinstallationdirectories:...Programnames:...Systemtypes:...OptionalFeatures:--disable-FEATUREdonotincludeFEATURE(sameas--enable-FEATURE=no)--enable-FEATURE[=ARG]includeFEATURE[ARG=yes]--enable-maintainer-modeenablemakerulesanddependenciesnotuseful(andsometimesconfusing)tothecasualinstaller--disable-dependency-trackingspeedsupone-timebuild--enable-dependency-trackingdonotrejectslowdependencyextractors--enable-static[=PKGS]buildstaticlibraries[default=no]--enable-shared[=PKGS]buildsharedlibraries[default=yes]--enable-fast-install[=PKGS]optimizeforfastinstallation[default=yes]--disable-libtool-lockavoidlocking(mightbreakparallelbuilds)--enable-lfsTurnonLargeFileSystem(default)--disable-ipv6disableIPv6supportOptionalPackages:--with-PACKAGE[=ARG]usePACKAGE[ARG=yes]--without-PACKAGEdonotusePACKAGE(sameas--with-PACKAGE=no)--with-gnu-ldassumetheCcompilerusesGNUld[default=no]--with-pictrytouseonlyPIC/non-PICobjects[default=useboth]--with-tags[=TAGS]includeadditionalconfigurations[automatic]--with-mysql[=PATH]IncludeMySQLsupport.PATHisthepathtomysql_config--with-ldapenableLDAPsupport--with-attrenableextendedattributesupport--with-valgrindenableinternalsupportforvalgrind--with-openssl[=DIR]Includeopensslsupport(defaultno)--with-openssl-includes=DIROpenSSLincludes--with-openssl-libs=DIROpenSSLlibraries--with-kerberos5useKerberos5supportwithOpenSSL--with-pcreEnablepcresupport(defaultyes)--with-bzip2Enablebzip2supportformod_compress--with-famfam/gaminforreducingnumberofstat()calls--with-webdav-propspropertiesinmod_webdav--with-gdbmgdbmstorageformod_trigger_b4_dl--with-memcachememcachedstorageformod_trigger_b4_dl--with-lualuaengineformod_cmlSomeinfluentialenvironmentvariables:...
复制代码
如上所述,可经由过程Cprefix指定装置路径,默许装置在/usr/local下。可以指定启用哪些特点(插件),禁用哪些特点(插件)。假定我们要把lighttpd装置到/usr/local/lighttpd-1.4.9上面。
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件
复制代码
设置装备摆设文件很直不雅清楚明了,普通只需把server.document-root、server.errorlog、accesslog.filename改成你的现实目次和文件名字就能够了。
  1. $sbin/lighttpd-flighttpd.conf#启动lighttpd办事$psaux|greplighttpdwww154030.00.928601148?S00:150:00sbin/lighttpd-f
复制代码
这就完成了从装置到启动的全部进程,很简略吧。从最初一行的输入可以看出,lighttpd是单过程办事的,这和apache纷歧样(或许是它的稳固性不如apache的一个缘由)。
(2)整合php和fastcgi
以php-4.3.11为例,编译PHP的时刻,不克不及指定Cwith-apxs选项,编译敕令行年夜致以下:
  1. $./configure...--enable-force-cgi-redirect--enable-fastcgi$make$sapi/cgi/php-vPHP4.3.11(cgi-fcgi)(built:Jan30200600:12:34)Copyright(c)1997-2004ThePHPGroupZendEnginev1.3.0,Copyright(c)1998-2004ZendTechnologies
复制代码
make完了后,会在sapi/cli目次生成敕令行下的php法式,sapi/cgi下生成fastcgi下的php法式。假如履行sapi/cgi下的php显示版本号,你会发明有cgi-fcgi的解释,这就注解你胜利了。
  1. $mkdir/usr/local/lighttpd-1.4.9/fcgi$cpsapi/cgi/php/usr/local/lighttpd-1.4.9/fcgi/$vi/usr/local/lighttpd-1.4.9/lighttpd.conf
复制代码
我们树立一个子目次fcgi用来保留一切的fast-cgi法式,然后把php拷贝到该目次下。编纂lighttpd.conf,以下所示:
  1. ...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通讯有两种方法:经由过程Unixsocket通讯,如以上PHP的启动;经由过程TCP/IPsocket通讯。Lighttpd支撑基于fastcgi的负载平衡,不外我没测验考试过。
关于fastcgi的协定标准,请参考http://www.fastcgi.com/,以下是我本身写的一个fastcgi的设置装备摆设样例:
  1. 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会招致要求掉败。
(3)制造lighttpd启动剧本
每次启动lighttpd时我们要指定设置装备摆设文件的地位,停滞lighttpd时要先找到过程号,然后用kill发送停滞旌旗灯号,有点太费事了。好在lighttpd自带了一个剧本法式能帮助完成这些操作,只需略微改改就可以用了,那就是源码目次doc/rc.lighttpd和doc/rc.lighttpd.redhat,后者公用于RedHatLinux。重要的修改的地方在于:
  1. ...if[-z"$LIGHTTPD_CONF_PATH"];thenLIGHTTPD_CONF_PATH="/usr/local/lighttpd-1.4.9/lighttpd.conf"fi...lighttpd="/usr/local/lighttpd-1.4.9/usr/sbin/lighttpd"...
复制代码
用这个剧本治理lighttpd是否是便利多了。
(4)Lighttpd和OpenSSL
Lighttpd默许不编译ssl模块,所以必需在编译的时刻明白指定Cwith-openssl,然后再生成自签订的办事器证书或许从CA那边获得。生成自签订证书的办法以下:
  1. $opensslreq-new-x509-keyoutserver.pem-outserver.pem-days365-nodes
复制代码
Lighttpd请求证书和私匙保留在统一个文件里,假如是离开的,则须要归并:
  1. $cathost.keyhost.crt>host.pem
复制代码
设置装备摆设lighttpd.conf,年夜致模样以下:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件0
复制代码
你可以针对某个虚拟主机做如许的设置,然则因为SSL任务在TCP层,所以不克不及设置基于称号的虚拟主机,只能设置基于端口的。以下是一个设置装备摆设样例:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件1
复制代码
(5)设置装备摆设目次列表
修正lighttpd.conf,年夜致以下所示:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件2
复制代码
(6)设置装备摆设CGI
修正lighttpd.conf,起首须要启动mod_cgi,然后在static-file.exclude-extensions中指定cgi文件的扩大名,最初经由过程cgi.assign设置装备摆设指令停止联系关系。
关于带扩大名且须要特定解析法式履行的CGI,可以指定解析法式的路径,好比:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件3
复制代码
关于带扩大名切不须要特定解析法式就可以履行的CGI,可指定解析法式为空,好比:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件4
复制代码
关于不带扩大名的CGI法式,只能经由过程固定路径存取了,好比:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件5
复制代码
(7)设置装备摆设虚拟主机
设置装备摆设基于端口的虚拟主机上文有所描写,基于称号的虚拟主机也很简略。修正lighttpd.conf,启动模块mod_simple_vhost,然后指定你的虚拟主机信息,好比:
  1. $./configure--prefix=/usr/local/lighttpd-1.4.9$make$makeinstall$cpdoc/lighttpd.conf/usr/local/lighttpd-1.4.9/#拷贝设置装备摆设文件$cd/usr/local/lighttpd-1.4.9$vilighttpd.conf#修正设置装备摆设文件6
复制代码
Lighttpd重视于速度,而Apache重视于稳固性和功效,怎样选择还得看详细的运用。
2.解压、装置、设置装备摆设
shell>tarzxvflighttpd-1.5.0-r1691.tar.gz
shell>cdlighttpd-1.5.0
shell>./configureCprefix=/usr/local/lighttpd
shell>./make
shell>./makeinstall
shell>cpdoc/rc.lighttpd.redhat/etc/rc.d/init.d/lighttpd
shell>chmod777/etc/rc.d/init.d/lighttpd
shell>cpdoc/sysconfig.lighttpd/etc/sysconfig/lighttpd
shell>mkdir/etc/lighttpd
shell>cpdoc/lighttpd.conf/etc/lighttpd/lighttpd.conf
shell>chkconfiglighttpdon

接上去翻开/etc/rc.d/init.d/lighttpd修正lighttpd的值以下
lighttpd=”/usr/local/lighttpd/sbin/lighttpd”
翻开/etc/lighttpd/lighttpd.conf修正办事的端口(默许是80),和文档根目次的路径(默许是/www/pages)后启动lighttpd办事
shell>servicelighttpdstart
更多关于lighttpd的设置装备摆设请看lighttpd的文档
附注

在lighttpd中可以经由过程上面的设置装备摆设来完成天天一个拜访日记文件
accesslog.filename=“|/usr/local/lighttpd/bin/rotatelogs/usr/local/lighttpd/logs/access_%Y%m%d.log86400″
个中rotatelogs直接从apache的bin目次拷贝过去便可。


如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!
变相怪杰 该用户已被删除
沙发
发表于 2015-1-16 22:30:18 | 只看该作者

CentOS教程之Lighttpd 的装置设置装备摆设,参加SSL拜访

选择一些适于初学者的Linux社区。
愤怒的大鸟 该用户已被删除
板凳
发表于 2015-1-25 17:26:00 | 只看该作者
安装一个新的软件时先看README,再看INSTALL然后看FAQ,最后才动手安装,这样遇到问题就知道为什么。如果Linux说明文档不看,结果出了问题再去论坛来找答案反而浪费时间。
柔情似水 该用户已被删除
地板
发表于 2015-2-3 12:44:05 | 只看该作者
熟读Linux系统有关知识,如系统目录树,有关内容可购书阅读或搜索论坛。
蒙在股里 该用户已被删除
5#
发表于 2015-2-9 03:29:41 | 只看该作者
Linux是参照Unix思想设计的,理解掌握Linux必须按照Unix思维来进行。思想性的转变比暂时性的技术提高更有用,因为他能帮助你加快学习速度。
活着的死人 该用户已被删除
6#
发表于 2015-2-26 22:03:49 | 只看该作者
随着IT从业人员越来越多,理论上会有更多的人使用Linux,可以肯定,Linux在以后这多时间不会消失。
不帅 该用户已被删除
7#
发表于 2015-3-8 18:46:15 | 只看该作者
编程学习及开发,Linux是免费,开源的操作系统,并且可开发工具相当多,如果您支持自由软件,一定要同广大热爱自由软件人士一同为其不懈努力。
透明 该用户已被删除
8#
发表于 2015-3-16 16:12:24 | 只看该作者
虽然大家都比较喜欢漂亮的mm,但是在学 linux 的过程中,还是要多和“男人”接触一下:P 遇到问题的时候,出来看说和上网查之外,就是要多用 linux 下的 man 命令找找帮助。
谁可相欹 该用户已被删除
9#
发表于 2015-3-23 00:46:06 | 只看该作者
发问的时候一定要注意到某些礼节。因为Linux社区是一个松散的组织、也不承担回复每个帖子的义务。它不是技术支持。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-9-28 01:19

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表