`

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
分享到:
评论

相关推荐

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

    简单的一键部署PHP调试环境,适合初学者。集成最新的Apache+Nginx+LightTPD+PHP+MySQL+phpMyAdmin+Zend Optimizer+Zend Loader

    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,有专门的控制面板。...

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

    centos7下安装测试成功的所有安装包整合

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

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

    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测试通过,其他自测 直接...

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

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

    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+cgi的代码包

    使用lighttpd的开源代码成功搭建支持cgi的代码包

    lighttpd+php in android

    参考了网上的一些资源和信息, lighttpd是自己编译出来的,php-cgi是网上下载,合起来可以在android上使用。 里面也包括了配置文件。

    phpstudy_phpstudy_

    phpStudy是一个PHP调试...该程序包集成最新的Apache+PHP+MySQL+phpMyAdmin+ZendOptimizer,一次性安装,无须配置即可使用,是非常方便、好用的PHP调试环境。该程序不仅包括PHP调试环境,还包括了开发工具、开发手册等。

    php+mysql+tomcat集成开发环境

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

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

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

    phpStudy 14种合集 自由切换 + phpfind + phpLight(解压版)

    phpStudy 2013.6.20 (大小35M) 14种合集 自由切换 PHP 5.2.17 新型的CGI程序编写语言,易学易用、速度快、跨平台。 PHP 5.3.26 新型的CGI...此为超级合集全面包括apache+nginx+lighttpd+IIS+php5.2,5.3,5.4,5.5

    phpStudy2016+VC11.zip

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

    最新lighttpd源码 lighttpd-1.4.22

    Lighttpd是一个德国人领导的开源软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的web server环境。具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点。lighttpd是...

    lighttpd 安装配置

    详细介绍了lighttpd 安装与配置。

    suse linux下安装php5、Lighttpd .

    use linux下安装php5、Lighttpd 1.下载各种PHP5需要的相关安装包(如jpeg8、libpng、freetype、zlib、GD库、curl、libxml2==),编译,安装,注意与服务器版本相同。 a.64位服务器对软件的编译: CFLAGS="-O3 -...

    varnish+lighttpd配置

    varnish+lighttpd配置

Global site tag (gtag.js) - Google Analytics