`

lighttpd 1.4.21 + php 5.2.9 + fcgi + discuz5.5安装设置

阅读更多

一。安装php5.2.9

./configure  --prefix=/opt/app/php-cgi --enable-fastcgi  --enable-discard-path --enable-force-cgi-redirect --enable-sockets --disable-debug --with-gd --enable-gd-native-ttf --with-mysql  --with-config-file-path=/etc/php-cgi

 

注意修改/etc/php-cgi/php.ini

cgi.fix_pathinfo = 1

 

make 
sudo make install

 

二。安装ZendOptimizer-3.3.3和eaccelerator

 

  • APC + Apache = Best performance
  • Memcached + Nginx = Best performance
  • Xcache + Lighttpd = Best performance

 

 

1.PHP缓冲(加速)首选xcache,兼容性和性能表现都非常优秀。

2.如果你的PHP环境需要Zend Optimizer,就安装eAccelerator,并把Zend Optimizer的压缩级别调到0。
zend_optimizer.optimization_level=0

 

ZendOptimizer安装很容易,不表

eaccelerator安装:

export PHP_PREFIX="/opt/app/php-cgi"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make
sudo make install

 

在/etc/php-cgi/php.ini中添加如下

zend_extension="/opt/app/php-cgi/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.log_file = "/var/log/eaccelerator_log"

[Zend]
zend_extension_manager.optimizer=/opt/app/Zend-3.3/lib/Optimizer-3.3.3
zend_extension_manager.optimizer_ts=/opt/app/Zend-3.3/lib/Optimizer_TS-3.3.3
zend_optimizer.version=3.3.3
zend_extension=/opt/app/Zend-3.3/lib/ZendExtensionManager.so
zend_extension_ts=/opt/app/Zend-3.3/lib/ZendExtensionManager_TS.so
zend_optimizer.optimization_level=0

三。安装lighttpd1.4.22

./configure --with-fam --prefix=/opt/app/lighttpd-bbs --sysconfdir=/etc/lighttpd-bbs

 

groupadd www
useradd -g www -s /sbin/nologin -d /dev/null www

 

配置:

/etc/lighttpd-bbs/lighttpd.conf

 

server.modules              = (
                               "mod_rewrite",
                               "mod_redirect",
#                               "mod_alias",
                                "mod_access",
#                               "mod_cml",
#                               "mod_trigger_b4_dl",
#                               "mod_auth",
                               "mod_status",
#                               "mod_setenv",
                               "mod_fastcgi",
#                               "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
#                               "mod_rrdtool",
                                "mod_accesslog" )

server.document-root        = "/opt/webapps/bbs"

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

# files to check for if .../ is requested
index-file.names            = ("index.php", "index.html",
                                "index.htm", "default.htm" )

## set the event-handler (read the performance section in the manual)
 server.event-handler = "linux-sysepoll" # needed on OS X

# mimetype mapping
mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "application/ogg",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jar"          =>      "application/x-java-archive",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",

 ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar",
  # default mime type
  ""              =>      "application/octet-stream",
 )

#### accesslog module
accesslog.filename          = "|/usr/local/sbin/cronolog /var/log/httpd/bbs-access.%Y%m%d.log"

url.access-deny             = ( "~", ".inc" )

$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable"
}
#$HTTP["referer"] !~ "^($|http://*\.test\.com)" {
        #$HTTP["url"] =~ "\.(js|css|gif|jpg|jpeg)$" {
#               url.access-deny = ( ".js",".css",".gif",".jpg",".jpeg")
        #}
#}

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".asp")

server.port                = 80

## bind to localhost (default: all interfaces)
server.bind                = "1.2.3.4"
server.name = "bbs.test.com"

## error-handler for status 404
#server.error-handler-404   = "/error-handler.html"
#server.error-handler-404   = "/error-handler.php"

## to help the rc.scripts
#server.pid-file            = "/var/run/lighttpd.pid"




## change uid to <uid> (default: don't care)
server.username            = "xxx"

## change uid to <uid> (default: don't care)
server.groupname           = "daemon"

#### compress module
compress.cache-dir         = "/tmp/lighttpd-bbs/compress/"
compress.filetype          = ("text/plain", "text/html","text/javascript","text/css")

fastcgi.debug=0
fastcgi.server = ( ".php" => ((
                     "socket" => "/tmp/php-bbs.socket",
                     "broken-scriptfilename" => "enable"
                 )))


#### SSL engine
ssl.engine                 = "disable"
#ssl.pemfile                = "/etc/ssl/private/lighttpd.pem"

#### status module
#status.status-url          = "/server-status"
#status.config-url          = "/server-config"
status.statistics-url = "/server-statistics"

#### url handling modules (rewrite, redirect, access)
#url.rewrite                = ( "^/$"             => "/server-status" )
#url.redirect               = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )
#### both rewrite/redirect support back reference to regex conditional using %n
#$HTTP["host"] =~ "^www\.(.*)" {
#  url.redirect            = ( "^/(.*)" => "http://%1/$1" )
#}
url.rewrite                = (
         "^/archiver/([a-z0-9\-]+\.html)$" => "archiver/index.php?$1",
         "^/forum-([0-9]+)-([0-9]+)\.html$" => "forumdisplay.php?fid=$1&page=$2",
         "^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "viewthread.php?tid=$1&extra=page%%53D$3&page=$2",
         "^/space-(username|uid)-(.+)\.html$" => "space.php?$1=$2",
         "^/tag-(.+)\.html$" => "tag.php?name=$1",
        "^/profile-(username|uid)-(.+)\.html$" => "viewpro.php?$1=$2",
        "^/upload(.*)$" => "/blog$1"
)

#### expire module
#expire.url                 = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")

#### ssi
#ssi.extension              = ( ".shtml" )

#### setenv
#setenv.add-request-header  = ( "TRAV_ENV" => "mysql://user@host/db" )
#setenv.add-response-header = ( "X-Secret-Message" => "42" )


server.max-keep-alive-requests = 128
server.max-keep-alive-idle = 1

server.network-backend = "linux-sendfile"
server.max-fds = 8192

server.stat-cache-engine = "fam"
#server.use-noatime = "enable"
#server.max-stat-threads = 1
#server.max-read-threads = 2
#server.force-lowercase-filenames = "enable"
server.max-request-size = 20480
server.max-read-idle = 60
server.max-write-idle = 60

 

四,lighttpd启动脚本:

 

/etc/init.d/lighttpd-bbs

#!/bin/sh
#
# lighttpd     Startup script for the lighttpd server
#
# chkconfig: - 86 16
# description: Lightning fast webserver with light system requirements
#
# processname: lighttpd
# config: /etc/lighttpd-bbs/lighttpd.conf
# config: /etc/sysconfig/lighttpd
# pidfile: /var/run/lighttpd-bbs.pid
#
# Note: pidfile is assumed to be created
# by lighttpd (config: server.pid-file).
# If not, uncomment 'pidof' line.

# Source function library
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/lighttpd ]; then
        . /etc/sysconfig/lighttpd
fi

if [ -z "$LIGHTTPD_CONF_PATH" ]; then
        LIGHTTPD_CONF_PATH="/etc/lighttpd-bbs/lighttpd.conf"
fi

prog="lighttpd-bbs"
lighttpd="/opt/app/lighttpd-bbs/sbin/lighttpd"
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        daemon $lighttpd -f $LIGHTTPD_CONF_PATH
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
   echo -n $"Stopping $prog: "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

reload() {
        echo -n $"Reloading $prog: "
        killproc $prog -HUP
        RETVAL=$?
        echo
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        reload)
                reload
                ;;
        status)
                status $lighttpd
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
                RETVAL=1
esac

exit $RETVAL

 

 

五、安装spawn-fcgi

下载spawn-fcgi-1.6.0

./configure --prefix=/opt/app/spawn-fcg
make 
sudo make install

 

六、fastcgi启动脚本

 /etc/init.d/spwan-php-bbs.sh

#!/bin/bash
#
# fcgi     Startup script for fcgi
#
# processname: fcgi

# Source function library
. /etc/rc.d/init.d/functions

## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/opt/app/spawn-fcgi/bin/spawn-fcgi"

## ABSOLUTE path to the PHP binary
FCGIPROGRAM="/opt/app/php-cgi/bin/php-cgi"

## TCP port to which to bind on localhost
#FCGIPORT="1026"
FCGI_SOCKET="/tmp/php-bbs.socket"

FCGI_PIDFILE="/var/run/spawn-fcgi-bbs.pid"

## number of PHP children to spawn
PHP_FCGI_CHILDREN=20

## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=500

## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1"

# allowed environment variables, separated by spaces
ALLOWED_ENV="SHELL PATH USER"

## if this script is run as root, switch to the following user
USERID=rsync
GROUPID=daemon


################## no config below this line

if test x$PHP_FCGI_CHILDREN = x; then
 PHP_FCGI_CHILDREN=5
fi

export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS


ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
if test x$UID = x0; then
  #EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN"
  EX="$SPAWNFCGI -s $FCGI_SOCKET -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN -P $FCGI_PIDFILE"
else
  #EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN"
  EX="$SPAWNFCGI -s $FCGI_SOCKET -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN -P $FCGI_PIDFILE"
fi

# copy the allowed environment variables
E=

for i in $ALLOWED_ENV; do
  E="$E $i=${!i}"
done

# clean the environment and set up a new one
#env - $E $EX




prog="fcgi-bbs" 



RETVAL=0

start() {
        echo -n $"Starting $prog: " 
        daemon env - $E $EX
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: " 
        rm -f $FCGI_PIDFILE $FCGI_SOCKET
        killproc $FCGIPROGRAM
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                stop
                start
                ;;
        condrestart)
                if [ -f /var/lock/subsys/$prog ]; then
                        stop
                        start
                fi
                ;;
        status)
                status $FCGIPROGRAM
                RETVAL=$?
                ;;
        *)
                echo $"Usage: $0 {start|stop|restart|condrestart|status}" 
                RETVAL=1
esac

exit $RETVAL

 

 

 

 

 

 

 

0
0
分享到:
评论

相关推荐

    lighttpd+mysql+php tar.gz安装包整合

    这里我们关注的是"lighttpd+mysql+php"的集成安装,特别适用于轻量级服务器需求,例如开发或测试环境。这个压缩包文件集合包含了在CentOS7系统上成功安装和测试的所有组件,包括lighttpd(一个轻量级HTTP服务器)、...

    套件php 集成最新的Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend Optimizer+Zend Loader

    这个工具包特别适合PHP初学者,因为它提供了一键式安装和配置功能,简化了通常需要手动设置的复杂过程。 首先,Apache、Nginx和LightTPD是三种流行的Web服务器软件。Apache是最广泛使用的开源HTTP服务器,具有丰富...

    phpLight(LightTPD+PHP集成包) v2014

    phpLight 2014 是网上首套LightTPD+PHP集成包,集成最新Lighttpd+PHP+MySQL+SQL-Front+Zend Guard Loader+XCache。纯绿色,安装后无需再配置。支持系统服务和非服务两种启动方式,自由切换。一次性安装无需再安装,...

    phpStudy 最新 Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend 稳定 强大

    该程序包集成最新的Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend Optimizer+Zend Loader,一次性安装,无须配置即可使用,是非常方便、好用的PHP调试环境。该程序绿色小巧简易迷你仅有35M,有专门的控制面板。...

    phpLight 2013 网上首套LightTPD+PHP集成包

    phpLight 2013 是网上首套LightTPD+PHP集成包, 集成最新Lighttpd+PHP+MySQL+SQL-Front+Zend Guard Loader+XCache。 纯绿色,安装后无需再配置。支持系统服务和非服务两种启动方式,自由切换。 一次性安装无需再安装...

    在安卓中创建 lighttpd+mysql+php的服务器-almp7.zip

    在安卓中创建 lighttpd+mysql+php的服务器_almp7.zip

    lighttpd+php in android

    以下是对"lighttpd+php in android"这个主题的详细说明。 **Lighttpd** Lighttpd是一款开源、快速、低内存占用的HTTP服务器,特别适合资源有限的设备,如Android手机或平板电脑。它的设计目标是提供高效的服务,...

    Openwrt里架设Lighttpd+PhP5+MYSQL环境标准教程.pdf

    "Openwrt里架设Lighttpd+PhP5+MYSQL环境标准教程" 本教程旨在指导读者在Openwrt系统中架设Lighttpd+PhP5+MYSQL环境,实现Web服务器搭建。以下是相关知识点的详细解释: 一、硬件准备 * 路由器:需要一台路由器,...

    搭建lighttpd+cgi的代码包

    【搭建lighttpd+cgi的代码包】 在Web服务器领域,lighttpd是一个轻量级且高效的HTTP服务器,因其低内存占用和高速度而受到欢迎。CGI(Common Gateway Interface)则是一种标准,允许Web服务器执行外部程序并返回...

    veket5.3 搭建web平台建站 lighttpd + php + mysql for veket 一键安装包

    Veket 官方论坛 lanwairen123 打包的 pet 直接双击安装即可,非原创,纯属分享。 在veket 上安装 php mysql 环境,随身的 php 服务器,php 5.2 + mysql 5.1。 veket 5.27 + veket 5.30测试通过,其他自测 直接...

    fcgi-2.4.1-SNAP-0910052249.tar.bz2

    我是用lighttpd+nginx+spawn-fcgi+fcgi-2.4.1搭建环境。使用C语言编写后台程序。goahead也可以用。apt install lighttpdapt install nginxapt install spawn-fcgitar -xjvf fcgi-2.4.1-SNAP-0910052249.tar.bz2cd ...

    nServer-v2.1023[FTP + MYSQL + HTTP + PHP(FCGI)]

    功能: FTP + MYSQL + HTTP + PHP(FCGI) 作者: 若海[mail@anrip.com] & 尛岢[mod@kerring.net] & 小小宇[sos07@qq.com] 主页: http://www.anrip.com 说明: xServer是业内首家通过CMD界面管理所有服务并实现标准...

    lighttpd 安装配置

    ### Lighttpd安装与配置详解 #### 一、前言 Lighttpd是一款开源的、高性能的、符合标准的Web服务器软件,适用于Unix-like系统,包括Linux、BSD、Solaris等。它以其轻量级、高效率的特点,在处理高并发连接方面表现...

    Linuxlighttpd+php+mysql+Discuz论坛.pdf

    本教程将详细介绍如何在Linux环境下使用lighttpd作为Web服务器,结合php和mysql数据库来搭建Discuz论坛。首先,我们来看lighttpd的安装与配置。 1. 安装配置LIGHTTPD Lighttpd是一款轻量级、高性能的Web服务器,...

    php+mysql+tomcat集成开发环境

    该程序包集成最新的Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend Optimizer+Zend Loader,一次性安装,无须配置即可使用,是非常方便、好用的PHP调试环境。该程序绿色小巧简易迷你仅有35M,有专门的控制面板。...

    lighttpd安装全集

    《lighttpd安装全集——在CentOS 6.x系统中的详细步骤》 Lighttpd,一款轻量级且高性能的Web服务器,以其低内存占用和高效能特性,在Linux和其他操作系统上广泛使用。本文将详细介绍如何在CentOS 6.x系统上安装并...

    LIGHTTTP配置

    若要支持Ruby on Rails,需要安装fcgi以及Rails应用的dispatch.fcgi: ```ini fastcgi.server += ( ".fcgi" =&gt; ( "rails" =&gt; ( "socket" =&gt; "/run/lighttpd/rails-fastcgi.sock", "bin-path" =&gt; "/path/to/rails...

    Nginx+PHP+MySQL集成包phpfind 2013 绿色免安装版

    2. 此为Nginx+PHP方案,需要apache+php方案的请到www.phpStudy.net下载phpStudy,Lighttpd+PHP方案下载phpLight。 3. 重装系统后或相关服务丢失时,只需要点一下『运行模式-应用』即可,更改路径自动启动。 4. 可...

    varnish+lighttpd配置

    3. **安全设置**:确保Varnish和Lighttpd的安全配置,避免被攻击。 4. **日志分析**:定期分析Varnish和Lighttpd的日志,找出性能瓶颈和优化点。 通过Varnish和Lighttpd的组合,你可以构建一个高效、灵活的Web...

    suse linux下安装php5、Lighttpd .

    ### SUSE Linux 下安装 PHP5 和 Lighttpd 的详细步骤 在 SUSE Linux 系统中安装 PHP5 和 Lighttpd 需要遵循一系列具体的步骤。本文将详细介绍这一过程中的关键步骤和技术要点,帮助读者顺利完成安装配置。 #### 1....

Global site tag (gtag.js) - Google Analytics