ORF反垃圾邮件系统

邮件服务器-邮件系统-邮件技术论坛(BBS)

 找回密码
 会员注册
查看: 8046|回复: 0
打印 上一主题 下一主题

[转帖]搭建一个轻量级服务器环境-LIGHTTPD + MYSQL + PHP(FAST-CGI)

[复制链接]
跳转到指定楼层
顶楼
发表于 2005-11-30 09:24:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
OS: REDHAT/CENTOS<br>
<br>
Lighttp是一个新兴的安全,高效,兼容性都非常好的WEB服务器软件。相对APACHE来说lighttpd的显著特点是:非常低的内存占用,非常快的相应速度。今天我在LINUX上配置了一下感觉的确不错,在这里和大家分享一下。安装lighttpd前需要预装下列软件包:<br>
<br>
pcre<br>
zlib<br>
pcre-devel<br>
zlib-devel<br>
<br>
1.安装配置lighttpd<br>
<br>
1.1 首先创建运行lighttpd的用户和组<br>
<br>
# groupadd lighttpd<br>
# useradd -g lighttpd -s /sbin/nologin -d /dev/null lighttpd<br>
<br>
1.2 开始安装lighttpd<br>
<br>
# wget <a target=_blank href=http://www.lighttpd.net/download/lighttpd-1.4.8.tar.gz>http://www.lighttpd.net/download/lighttpd-1.4.8.tar.gz</a><br>
# tar -zxvf lighttpd-1.4.8.tar.gz<br>
# cd lighttpd-1.4.8<br>
# ./configure --prefix=/usr/local/lighttpd<br>
<br>
# make<br>
# make install<br>
<br>
# mkdir /usr/local/lighttpd/conf<br>
# mkdir /usr/local/lighttpd/log<br>
<br>
# mv ./doc/lighttpd.conf /usr/local/lighttpd/conf/<br>
# cp ./doc/rc.lighttpd.redhat /etc/init.d/lighttpd<br>
<br>
1.3 配置lighttpd<br>
<br>
# vi /usr/local/lighttpd/conf/lighttpd.conf<br>
================+===============+================<br>
server.modules = (<br>"mod_rewrite",<br>"mod_redirect",<br>"mod_access",<br>"mod_fastcgi",<br>"mod_compress",<br>"mod_accesslog" )<br>
<br>
server.document-root = "/usr/local/lighttpd/html"<br>
server.errorlog = "/usr/local/lighttpd/log/lighttpd.error.log"<br>
accesslog.filename = "/usr/local/lighttpd/log/access.log"<br>
server.pid-file = "/var/run/lighttpd.pid"<br>
<br>
server.username = "lighttpd"<br>
server.groupname = "lighttpd"<br>
<br>
compress.cache-dir = "/tmp"<br>
compress.filetype = ("text/plain", "text/html")<br>
<br>
fastcgi.server = ( ".php" =><br>( "localhost" =><br>(<br>"socket" => "/tmp/php-fastcgi.socket",<br>"bin-path" => "/usr/local/php-fcgi/bin/php"<br>)<br>)<br>)<br>
================+===============+================<br>
<br>
# cp ./doc/spawn-php.sh /usr/local/lighttpd/bin/<br>
# chown -R lighttpd:lighttpd /usr/local/lighttpd<br>
<br>
2. 安装配置PHP(FAST-CGI)<br>
<br>
2.1 下载安装PHP<br>
<br>
# cd ..<br>
# wget <a target=_blank href=http://mirrors.easynews.com/php/php-4.3.10.tar.gz>http://mirrors.easynews.com/php/php-4.3.10.tar.gz</a><br>
# tar -zxvf php-4.3.10.tar.gz<br>
# cd php-4.3.10<br>
# ./configure \<br>
--prefix=/usr/local/php-fcgi \<br>
--enable-fastcgi --with-mysql \<br>
--enable-zend-multibyte \<br>
--with-config-file-path=/etc \<br>
--enable-discard-path \<br>
--enable-force-cgi-redirect<br>
<br>
# make<br>
# make install<br>
<br>
# cp php.ini-dist /etc/php.ini<br>
<br>
3. 安装配置EAccelerator(PHP加速器)<br>
<br>
3.1 下载安装EAccelerator<br>
<br>
# wget <a target=_blank href=http://kent.dl.sourceforge.net/sourceforge/eaccelerator/>http://kent.dl.sourceforge.net/sourceforge/eaccelerator/</a> \<br>
eaccelerator-0.9.4-rc1.tar.bz2<br>
# bunzip2 -d eaccelerator-0.9.4-rc1.tar.bz2<br>
# tar -xvf eaccelerator-0.9.4-rc1.tar<br>
# cd eaccelerator-0.9.4-rc1<br>
<br>
# export PHP_PREFIX="/usr/local/php-fcgi"<br>
# $PHP_PREFIX/bin/phpize<br>
# ./configure \<br>
--enable-eaccelerator=shared \<br>
--with-php-config=$PHP_PREFIX/bin/php-config<br>
# make<br>
# make install<br>
# cat eaccelerator.ini >> /etc/php.ini<br>
<br>
3.2 配置PHP变量<br>
<br>
# vi /etc/php.ini<br>
================+===============+================<br>
cgi.fix_pathinfo = 1<br>
extension_dir = "/usr/local/php-fcgi/lib/php/extensions/\<br>
no-debug-non-zts-20020429/"<br>
zlib.output_compression = On<br>
cgi.fix_pathinfo=1<br>
eaccelerator.cache_dir="/tmp"<br>
<br>
////下面的是关于eaccelerator的配置////<br>
<br>
zend_extension="/usr/local/php-fcgi/lib/php/extensions/no-debug-non-zts-20020429/eaccelerator.so"<br>
eaccelerator.shm_size = "0"<br>
eaccelerator.cache_dir = "/tmp"<br>
eaccelerator.enable = "1"<br>
eaccelerator.optimizer = "1"<br>
eaccelerator.debug = 0<br>
eaccelerator.log_file = "/var/log/eaccelerator_log"<br>
eaccelerator.name_space = ""<br>
eaccelerator.check_mtime = "1"<br>
eaccelerator.filter = ""<br>
eaccelerator.shm_max = "0"<br>
eaccelerator.shm_ttl = "0"<br>
eaccelerator.shm_prune_period = "0"<br>
eaccelerator.shm_only = "0"<br>
eaccelerator.compress = "1"<br>
eaccelerator.compress_level = "9"<br>
eaccelerator.keys = "shm_and_disk"<br>
eaccelerator.sessions = "shm_and_disk"<br>
eaccelerator.content = "shm_and_disk"<br>
eaccelerator.admin.name="yourusername" <br>
eaccelerator.admin.password="yourpassword"<br>
================+===============+================<br>
<br>
3.3 初始化PHP with FastCGI<br>
<br>
# vi /usr/local/lighttpd/bin/spawn-php.sh<br>
================+===============+================<br>
SPAWNFCGI="/usr/local/lighttpd/bin/spawn-fcgi"<br>
FCGIPROGRAM="/usr/local/php-fcgi/bin/php"<br>
USERID=lighttpd<br>
GROUPID=lighttpd<br>
================+===============+================<br>
<br>
# sh /usr/local/lighttpd/bin/spawn-php.sh<br>
<br>
4. 测试<br>
<br>
把/etc/init.d/lighttpd文件中不符的路径更改一下<br>
<br>
# chmod 755 /etc/init.d/lighttpd<br>
# chown root:root /etc/init.d/lighttpd<br>
# chkconfig --add lighttpd<br>
# chkconfig lighttpd on<br>
# service lighttpd start<br>
<br>
# ps afx | grep php<br>
<br>
12222 pts/2 S 0:00 \_ grep php<br>
12193 ? S 0:00 /usr/local/php-fcgi/bin/php<br>
12194 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12195 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12196 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12197 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12198 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12199 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12200 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12201 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12202 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
12203 ? S 0:00 \_ /usr/local/php-fcgi/bin/php<br>
<br>
最后在server.document-root目录中放一个test.php,用浏览器看看结果:<br>
<br>
<br>
<a target=_blank href=http://llzqq.3322.org/test.php>http://llzqq.3322.org/test.php</a><br>
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

小黑屋|手机版|Archiver|邮件技术资讯网

GMT+8, 2024-11-24 23:01

Powered by Discuz! X3.2

© 2001-2016 Comsenz Inc.

本论坛为非盈利中立机构,所有言论属发表者个人意见,不代表本论坛立场。内容所涉及版权和法律相关事宜请参考各自所有者的条款。
如认定侵犯了您权利,请联系我们。本论坛原创内容请联系后再行转载并务必保留我站信息。此声明修改不另行通知,保留最终解释权。
*本论坛会员专属QQ群:邮件技术资讯网会员QQ群
*本论坛会员备用QQ群:邮件技术资讯网备用群

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