正文:

在上一节中,我们已经搭建了MySQL数据库了,因此在这一节中,我主要讲解php的安装,以及php的运行环境Nginx的安装。参考(http://www.right.com.cn/forum/thread-89216-1-1.html

  • OPENWRT开始SFTP支持办法
root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install vsftpd openssh-sftp-server
root@OpenWrt:~# /etc/init.d/vsftpd enable
root@OpenWrt:~# /etc/init.d/vsftpd start
  • openwrt uhttpd更改默认端口
#vi /etc/config/uhttpd
list listen_http 0.0.0.0:80 --> list listen_http 0.0.0.0:8081
list listen_http '[::]:80'  --> list listen_http '[::]:8081'
list listen_https '0.0.0.0:443' -->list listen_https '0.0.0.0:445'
list listen_https '[::]:443'  -->list listen_https '[::]:445'

重启uhttpd
#/etc/init.d/uhttpd restart

一、PHP安装

  1. 安装php软件包。
opkg update
opkg install spawn-fcgi
opkg install php5 php5-cgi php5-fastcgi php5-mod-ctype php5-mod-dom php5-mod-hash php5-mod-iconv php5-mod-json php5-mod-mbstring php5-mod-mysqli php5-mod-mysql php5-mod-opcache php5-mod-openssl php5-mod-pdo-mysql php5-mod-pdo php5-mod-session php5-mod-tokenizer php5-mod-xml php5-mod-zip

在上述列表中,我安装了很多的php扩展支持,这些包可以根据自己的需要进行添加,并不是所有的php扩展包都需要安装的。

在此,列举几个较为重要的扩展:

php5:这个不用多说,php的主框架软件包,该软件不安装,下面的其他软件包都没用。

php5-cgi/php5-fastcgi: 网页交互的关键。

php5-mod-mysql / php-mod-pdo / php5-mod-pdo-mysql:这些是使用MySQL所必须的。

php5-mod-session:登录账号的关键

php5-mod-xml: xml解析

php5-mod-json: json支持

如果大家觉得空间足够,也可以一劳永逸(不推荐),将所有php5相关的包都安装:

opkg update
opkg install php5*
  1. 配置php

在php软件包安装完成之后,会在/etc下生成一个php.ini文件,该文件就是php的配置文件。我们可以根据自己的需要进行必要的配置。修改php.ini:

short_open_tag = on

#如果php显示“not found”时,将下面一行注释
#doc_root = "/mnt/sda3/www" 

#在Dynamic extension部分,将我们需要添加的扩展的注释都去掉“;”
extension=ctype.so
;extension=curl.so
extension=dom.so
;extension=exif.so
;extension=ftp.so
;extension=gd.so
;extension=gmp.so
extension=hash.so
extension=iconv.so
extension=json.so
;extension=ldap.so
extension=mbstring.so
;extension=mcrypt.so
extension=mysql.so
extension=mysqli.so
extension=opcache.so
extension=openssl.so
;extension=pcre.so
extension=pdo.so
extension=pdo-mysql.so
;extension=pdo-pgsql.so
;extension=pdo_sqlite.so
;extension=pgsql.so
extension=session.so
;extension=soap.so
;extension=sockets.so
;extension=sqlite.so
;extension=sqlite3.so
extension=tokenizer.so
extension=xml.so
;extension=xmlreader.so
;extension=xmlwriter.so
extension=zip.so

[Date]
#修改时区
date.timezone = Asia/Chongqing

[MySQL]
#修改MySQL的设置
mysql.default_socket = /var/run/mysqld.sock 

tips: 在修改时区的时候,需要添加zoneinfo,也就是前文提到的软件包 zoneinfo-asia.opkg和zoneinfo-core.opkg,如果不添加支持,在修改之后会报错。

本人使用的backfire里面是不带上述两个包的。


二、Nginx安装

  1. 安装Nginx软件包
opkg update
opkg install nginx
  1. 修改Nginx配置文件(/etc/nginx.conf)

准备工作:

(1)创建Nginx的工作目录:

mkdir /mnt/sda3/www

(2)增加Nginx的用户以及用户组:

opkg install shadow-useradd shadow-groupadd

#添加用户组
groupadd www
#添加用户到用户组www
useradd -g www www
#将Nginx的工作目录绑定到www用户
chown -R www:www /mnt/sda3/www

(3)修改Nginx的配置文件(/etc/nginx/nginx.conf):

原本的Nginx配置文件有些复杂,将其按照不同的功能分割成不同的配置文件:

user  www www;  #设定用户及其用户名
worker_processes  1;  #允许线程个数
pid        /var/run/nginx.pid;   #指定pid的存放位置
error_log  /var/log/nginx_error.log; #指定error.log的位置
events {
    use epoll;
    worker_connections  1024; #指定最大连接数
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    access_log  /var/log/nginx/access.log  main;  #access.log日志
    sendfile        on;
    tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    include vhost.conf; #server 配置文件
} 

(4)在/ect/nginx文件夹下创建host配置文件: vhost.conf

server {
    listen       8000;      #系统中原有httpd监听80
    server_name  localhost;
    root /mnt/sda3/www;  #网站的工作目录
    index  index.html index.htm index.php default.php;

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html; #error页面重定向
    location = /50x.html {
        root   html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~\.php$ {
        #将php脚本传递给FastCGIserver
        fastcgi_pass   127.0.0.1:9000; #FastCGI的server
        fastcgi_index  index.php;  
        fastcgi_param  SCRIPT_FILENAME   /mnt/sda3/www/$fastcgi_script_name; #fastcgi的参数
        include        fastcgi_params;   #fastcgi的具体配置文件
    }
}

(5) FastCGI具体配置: /etc/nginx/fastcgi_param

#解决文件类型解析错误的问题
if ( $request_filename ~* (.*)\.php ) {
        set $php_url $1;
}
if (!-e $php_url.php) {
        return 403;
}

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
#下面注释中的参数:脚本名,其设置需要注意。亲测有效
#fastcgi_param  SCRIPT_FILENAME   $document_root/$fastcgi_script_name;
fastcgi_param  SCRIPT_FILENAME    /mnt/sda3/www/$fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

(6)开启Nginx服务:

对于Nginx服务的开启有点麻烦。首先要开启fastcgi服务:

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi

如果要开机启动,将上述指令放置到/etc/rc.local脚本之下

如果rc.local 中有exit 0 ,记得注释掉,不然就不会开始监听9000端口。这个问题整了好久。。。。

开启Nginx服务

/etc/init.d/nginx enable
/etc/init.d/nginx start

三、Nginx+php+MySQL 测试

在/mnt/sda3/www文件夹下,分别放置以下文件进行测试:

在测试的时候,记得结合Nginx的日志文件:

/var/log/nginx/acesss.log
/var/log/nginx/error.log
  1. index.html(测试Nginx服务是否正常开启)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>this is a test file</title>
</head>
<body>
    <span>this is a html file</span>
</body>
</html>
  1. index.php(用于测试fastcgi是否工作正常)
<?php
    phpinfo();
?>
  1. php (测试文件名是否解释正常)
<?php
    echo date("Y-m-d h:i:s",time());
?>

四、 遇到的问题,以及解决方案

  1. 问题: 测试fastcgi是否工作的时候,页面显示“no input file specified ”。

(1)fastcgi:9000端口没有正常开启

在使用如下命令:

netstat-ant |grep 9000

9000端口没有开启。也就是说fastcgi服务没有开启。手动开启:

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi

(2)注意文件fastcgi_params是否正确,并且是唯一文件
位置在/etc/nginx/fastcgi_params

OK:Nginx+PHP+MySQL开发环境就成功移植到Openwrt平台上了。

五、Openwrt常用命令

ps 查看进程

top 查看进程占用内存高低

killall +进程名称

opkg remove --autoremove +包名

opkg remove --force-remove+包名


六、php5-fpm配置

php5-fpm.conf

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr otherwise
;include=/etc/php5/fpm/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /var/run/php5-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php5-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when 
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool process will inherit the master process priority
;         unless it specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select     (any POSIX os)
; - poll       (any POSIX os)
; - epoll      (linux >= 2.5.44)
; - kqueue     (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll  (Solaris >= 7)
; - port       (Solaris >= 10)
; Default Value: not set (auto detection)
; events.mechanism = epoll

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5-fpm.d/*.conf

php5-fpm.d/www.conf

; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = www
group = www

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000
#listen = /var/run/php5-fpm.sock

; Set listen(2) backlog.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 128

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. 
; Default Values: user and group are set as the running user
;                 mode is set to 0666
;listen.owner = www-data
;listen.group = www-data
;listen.mode = 0666

; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1

; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool processes will inherit the master process priority
;         unless it specified otherwise
; Default Value: no set
; priority = -19

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives. With this process management, there will be
;             always at least 1 children.
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
;  ondemand - no children are created at startup. Children will be forked when
;             new requests will connect. The following parameter are used:
;             pm.max_children           - the maximum number of children that
;                                         can be alive at the same time.
;             pm.process_idle_timeout   - The number of seconds after which
;                                         an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic
;pm = static

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 7

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 2

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 7

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 1024
;最大请求数:指一个php-fpm的工作进程在处理多少个请求后就终止掉。

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
;   pool                 - the name of the pool;
;   process manager      - static, dynamic or ondemand;
;   start time           - the date and time FPM has started;
;   start since          - number of seconds since FPM has started;
;   accepted conn        - the number of request accepted by the pool;
;   listen queue         - the number of request in the queue of pending
;                          connections (see backlog in listen(2));
;   max listen queue     - the maximum number of requests in the queue
;                          of pending connections since FPM has started;
;   listen queue len     - the size of the socket queue of pending connections;
;   idle processes       - the number of idle processes;
;   active processes     - the number of active processes;
;   total processes      - the number of idle + active processes;
;   max active processes - the maximum number of active processes since FPM
;                          has started;
;   max children reached - number of times, the process limit has been reached,
;                          when pm tries to start more children (works only for
;                          pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
;   pool:                 www
;   process manager:      static
;   start time:           01/Jul/2011:17:53:49 +0200
;   start since:          62636
;   accepted conn:        190460
;   listen queue:         0
;   max listen queue:     1
;   listen queue len:     42
;   idle processes:       4
;   active processes:     11
;   total processes:      15
;   max active processes: 12
;   max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
;   http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example: 
;   http://www.foo.bar/status?full
;   http://www.foo.bar/status?json&full
;   http://www.foo.bar/status?html&full
;   http://www.foo.bar/status?xml&full
; The Full status returns for each process:
;   pid                  - the PID of the process;
;   state                - the state of the process (Idle, Running, ...);
;   start time           - the date and time the process has started;
;   start since          - the number of seconds since the process has started;
;   requests             - the number of requests the process has served;
;   request duration     - the duration in µs of the requests;
;   request method       - the request method (GET, POST, ...);
;   request URI          - the request URI with the query string;
;   content length       - the content length of the request (only with POST);
;   user                 - the user (PHP_AUTH_USER) (or '-' if not set);
;   script               - the main script called (or '-' if not set);
;   last request cpu     - the %cpu the last request consumed
;                          it's always 0 if the process is not in Idle state
;                          because CPU calculation is done when the request
;                          processing has terminated;
;   last request memory  - the max amount of memory the last request consumed
;                          it's always 0 if the process is not in Idle state
;                          because memory calculation is done when the request
;                          processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
;   ************************
;   pid:                  31330
;   state:                Running
;   start time:           01/Jul/2011:17:53:49 +0200
;   start since:          63087
;   requests:             12808
;   request duration:     1250261
;   request method:       GET
;   request URI:          /test_mem.php?N=10000
;   content length:       0
;   user:                 -
;   script:               /home/fat/web/docs/php/test_mem.php
;   last request cpu:     0.00
;   last request memory:  0
;
; Note: There is a real-time FPM status monitoring sample web page available
;       It's available in: ${prefix}/share/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set 
;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The access log file
; Default: not set
;access.log = log/$pool.access.log

; The access log format.
; The following syntax is allowed
;  %%: the '%' character
;  %C: %CPU used by the request
;      it can accept the following format:
;      - %{user}C for user CPU only
;      - %{system}C for system CPU only
;      - %{total}C  for user + system CPU (default)
;  %d: time taken to serve the request
;      it can accept the following format:
;      - %{seconds}d (default)
;      - %{miliseconds}d
;      - %{mili}d
;      - %{microseconds}d
;      - %{micro}d
;  %e: an environment variable (same as $_ENV or $_SERVER)
;      it must be associated with embraces to specify the name of the env
;      variable. Some exemples:
;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
;  %f: script filename
;  %l: content-length of the request (for POST request only)
;  %m: request method
;  %M: peak of memory allocated by PHP
;      it can accept the following format:
;      - %{bytes}M (default)
;      - %{kilobytes}M
;      - %{kilo}M
;      - %{megabytes}M
;      - %{mega}M
;  %n: pool name
;  %o: ouput header
;      it must be associated with embraces to specify the name of the header:
;      - %{Content-Type}o
;      - %{X-Powered-By}o
;      - %{Transfert-Encoding}o
;      - ....
;  %p: PID of the child that serviced the request
;  %P: PID of the parent of the child that serviced the request
;  %q: the query string 
;  %Q: the '?' character if query string exists
;  %r: the request URI (without the query string, see %q and %Q)
;  %R: remote IP address
;  %s: status (response code)
;  %t: server time the request was received
;      it can accept a strftime(3) format:
;      %d/%b/%Y:%H:%M:%S %z (default)
;  %T: time the log has been written (the request has finished)
;      it can accept a strftime(3) format:
;      %d/%b/%Y:%H:%M:%S %z (default)
;  %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
;request_terminate_timeout = 20s

; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =

; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes

; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'. 
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

OpenWRT-Nginx-Mysql-PHP(一键安装脚本)

OpenWRT_LNMP_install.sh

#!/bin/sh
# Author Brick

opkg update
echo -e "\033[31m Software Update is Done\033[0m"
opkg install php5 php5-mod-mysql php5-fastcgi php5-cgi \
mysql-server nginx spawn-fcgi zoneinfo-core zoneinfo-asia shadow-groupadd shadow-useradd
echo -e "\033[31m Software install is Done\033[0m"
mkdir /web
groupadd www
useradd -g www www
chown -R www:www /web
echo -e "\033[31m User and WebPath Create Finshed\033[0m"
mv /etc/my.cnf /etc/my.cnf_bak
mv /tmp/my.cnf /etc/
/usr/bin/mysql_install_db --force
/etc/init.d/mysqld start
/usr/bin/mysqladmin -u root password admin
echo -e "\033[31m Mysql install is Done\033[0m"
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf_bak
mv /etc/nginx/fastcgi_params /etc/nginx/fastcgi_params_bak
mv /etc/php.ini /etc/php.ini_bak
mv /tmp/nginx.conf /etc/nginx/
mv /tmp/php.ini /etc/
mv /tmp/vhost.conf /etc/nginx/
mv /tmp/fastcgi_params /etc/nginx/
echo -e "\033[31m configer is Done\033[0m"
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi
/etc/init.d/nginx start
echo "<?php phpinfo(); ?>" > /web/index.php
echo "/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 2 -f /usr/bin/php-cgi" >> /etc/rc.local
echo "/etc/init.d/nginx start" >> /etc/rc.local
echo "/etc/init.d/mysqld start" >> /etc/rc.local

/etc/php.ini

[PHP]

zend.ze1_compatibility_mode = Off

; Language Options

engine = On
short_open_tag = On

; Allow ASP-style <% %> tags.
; http://php.net/asp-tags
asp_tags = Off

;precision =  12
precision =  14
y2k_compliance = On

;output_buffering = On
output_buffering = 4096

;output_handler =

;zlib.output_compression = Off 默认值为Off,你可以将其设置为On,或者output buffer size(默认为4k)
;zlib.output_compression_level = -1 代表压缩比,默认推荐设置压缩比值为6,可选范围为1-9,-1代表关闭php zlib(gzip)压缩
zlib.output_compression = On
;建议参数值是1~5,6以实际压缩效果提升不大,cpu占用却是几何增长
zlib.output_compression_level = 5
;zlib.output_handler必须保持注释掉,因为此参数和前面的设置冲突——官方的说法
;zlib.output_handler =
implicit_flush = Off
unserialize_callback_func =
;serialize_precision = 100
serialize_precision = 17

;open_basedir =
disable_functions =
disable_classes =

zend.enable_gc = On

; Colors for Syntax Highlighting mode.  Anything that's acceptable in
; <span style="color: ???????"> would work.
;highlight.string  = #DD0000
;highlight.comment = #FF9900
;highlight.keyword = #007700
;highlight.bg      = #FFFFFF
;highlight.default = #0000BB
;highlight.html    = #000000

;ignore_user_abort = On
;realpath_cache_size = 16k
;realpath_cache_ttl = 120

; Miscellaneous

expose_php = On

; Resource Limits
; Maximum execution time of each script, in seconds.
;max_execution_time = 30    
; Maximum amount of time each script may spend parsing request data.
;max_input_time = 60    
;max_input_nesting_level = 64
; Maximum amount of memory a script may consume.
;memory_limit = 8M  
memory_limit = 128M
max_file_uploads = 20
max_execution_time = 300
max_input_time = 600

; Error handling and logging

; Error Level Constants:
; E_ALL             - All errors and warnings (includes E_STRICT as of PHP 6.0.0)
; E_ERROR           - fatal run-time errors
; E_RECOVERABLE_ERROR  - almost fatal run-time errors
; E_WARNING         - run-time warnings (non-fatal errors)
; E_PARSE           - compile-time parse errors
; E_NOTICE          - run-time notices (these are warnings which often result
;                     from a bug in your code, but it's possible that it was
;                     intentional (e.g., using an uninitialized variable and
;                     relying on the fact it's automatically initialized to an
;                     empty string)
; E_STRICT          - run-time notices, enable to have PHP suggest changes
;                     to your code which will ensure the best interoperability
;                     and forward compatibility of your code
; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
;                     initial startup
; E_COMPILE_ERROR   - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR      - user-generated error message
; E_USER_WARNING    - user-generated warning message
; E_USER_NOTICE     - user-generated notice message
; E_DEPRECATED      - warn about code that will not work in future versions
;                     of PHP
; E_USER_DEPRECATED - user-generated deprecation warnings
;
; Common Values:
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
;error_reporting  =  E_ALL & ~E_NOTICE & ~E_STRICT
;将会向PHP报告发生的每个错误
error_reporting = E_ALL
;Off不显示满足上条?指令所定义规则的所有错误报告
display_errors = On
display_startup_errors = Off
;log_errors = Off
;开启错误日志
log_errors = On
;设置每个日志项的最大长度
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
;report_zend_debug = 0
track_errors = Off
;html_errors = Off
;docref_root = "/phpmanual/"
;docref_ext = .html
;error_prepend_string = "<font color=#ff0000>"
;error_append_string = "</font>"
; Log errors to specified file.
;指定产生的错误报告写入的日志文件位置
error_log = /var/log/php_errors.log
; Log errors to syslog.
;系统日志
;error_log = syslog

; Data Handling

;arg_separator.output = "&amp;"
;arg_separator.input = ";&"
variables_order = "EGPCS"
request_order = "GP"
register_globals = Off
register_long_arrays = Off
register_argc_argv = On
auto_globals_jit = On
post_max_size = 8M
;magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"

;default_charset = "iso-8859-1"
default_charset = "UTF-8"
;always_populate_raw_post_data = On
always_populate_raw_post_data = -1

; Paths and Directories

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;doc_root = "/www"
user_dir =
extension_dir = "/usr/lib/php"

;enable_dl = On
enable_dl = Off

;cgi.force_redirect = 1
;cgi.nph = 1
;cgi.redirect_status_env = ;
cgi.fix_pathinfo=1
;fastcgi.impersonate = 1;
;fastcgi.logging = 0
;cgi.rfc2616_headers = 0

; File Uploads

file_uploads = On
;upload_tmp_dir = "/tmp"
;upload_max_filesize = 2M
max_file_uploads = 20
file_uploads = On
upload_tmp_dir = "/mnt/sda2/www/nginx_temp"
upload_max_filesize = 200M
post_max_size = 220M

; Fopen wrappers

allow_url_fopen = On
allow_url_include = Off
;from="john@doe.com"
;user_agent="PHP"
default_socket_timeout = 60
;auto_detect_line_endings = Off

; Dynamic Extensions

extension=ctype.so
;extension=curl.so
extension=dom.so
;extension=exif.so
;extension=ftp.so
;extension=gd.so
;extension=gmp.so
extension=hash.so
extension=iconv.so
extension=json.so
;extension=ldap.so
extension=mbstring.so
;extension=mcrypt.so
extension=mysql.so
extension=mysqli.so
extension=opcache.so
extension=openssl.so
;extension=pcre.so
extension=pdo.so
extension=pdo-mysql.so
;extension=pdo-pgsql.so
;extension=pdo_sqlite.so
;extension=pgsql.so
extension=session.so
;extension=soap.so
;extension=sockets.so
;extension=sqlite.so
;extension=sqlite3.so
extension=tokenizer.so
extension=xml.so
;extension=xmlreader.so
;extension=xmlwriter.so
extension=zip.so

; Module Settings

[APC]
apc.enabled = 1
apc.shm_segments = 1    ;The number of shared memory segments to allocate for the compiler cache.
apc.shm_size = 4M   ;The size of each shared memory segment.

[Date]
;date.timezone =
date.timezone = PRC
;date.default_latitude = 31.7667
;date.default_longitude = 35.2333
;date.sunrise_zenith = 90.583333
;date.sunset_zenith = 90.583333

[filter]
;filter.default = unsafe_raw
;filter.default_flags =

[iconv]
;iconv.input_encoding = ISO-8859-1
;iconv.internal_encoding = ISO-8859-1
;iconv.output_encoding = ISO-8859-1

[sqlite]
;sqlite.assoc_case = 0

[sqlite3]
;sqlite3.extension_dir =

[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=

[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off

[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

[Session]
session.save_handler = files
session.save_path = "/tmp"
session.use_cookies = 1
;session.cookie_secure =
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor     = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = On
session.bug_compat_warn = On
session.referer_check =
session.entropy_length = 0
;session.entropy_file = /dev/urandom
session.entropy_file =
;session.entropy_length = 16
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 4
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="

[mbstring]
;mbstring.language = Japanese
;mbstring.internal_encoding = EUC-JP
;mbstring.http_input = auto
;mbstring.http_output = SJIS
;mbstring.encoding_translation = Off
;mbstring.detect_order = auto
;mbstring.substitute_character = none;
;mbstring.func_overload = 0
;mbstring.strict_detection = Off
;mbstring.http_output_conv_mimetype=
;mbstring.script_encoding=
mbstring.language = Chinese
mbstring.internal_encoding = UTF-8
mbstring.encoding_translation = On
mbstring.http_input = UTF-8
mbstring.http_output = UTF-8
mbstring.detect_order = UTF-8
mbstring.substitute_character = none

[gd]
;gd.jpeg_ignore_warning = 0

[exif]
;exif.encode_unicode = ISO-8859-15
;exif.decode_unicode_motorola = UCS-2BE
;exif.decode_unicode_intel    = UCS-2LE
;exif.encode_jis =
;exif.decode_jis_motorola = JIS
;exif.decode_jis_intel    = JIS

[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5

[sysvshm]
;sysvshm.init_mem = 10000

[ldap]
ldap.max_links = -1

[mcrypt]
;mcrypt.algorithms_dir=
;mcrypt.modes_dir=

[opcache]
;opcache.memory_consumption=8       ; 8M is the allowed minimum
;opcache.interned_strings_buffer=1
opcache.max_accelerated_files=200   ; 200 is the allowed minimum
;opcache.revalidate_freq=60
;opcache.fast_shutdown=1
opcache.enable_cli=1
opcache.enable=1
;opcache.log_verbosity_level=4

/etc/my.cnf

[client]
port        = 3306
socket      = /var/mysqld.sock
default-character-set = utf8

[mysqld]
skip-grant-tables

wait_timeout=1800
interactive_timeout=1800

user        = root
socket      = /var/mysqld.sock
port        = 3306
basedir     = /usr
character_set_server = utf8

############ Don't put this on the NAND #############
# Figure out where you are going to put the databases
# And run mysql_install_db --force
datadir     = /mnt/sda1/data/mysql/

######### This should also not go on the NAND #######
tmpdir      = /mnt/sda1/data/tmp/


skip-external-locking

bind-address        = 192.168.10.1

# Fine Tuning
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8

# Here you can see queries with especially long duration
#log_slow_queries   = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes

# The following can be used as easy to replay backup logs or for replication.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
#expire_logs_days   = 10
#max_binlog_size         = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name


[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 16M

/etc/init.d/nginx/nginx.conf

user www www; #设定用户及其用户名
worker_processes  1; #允许线程个数
worker_rlimit_nofile 65535; 
pid        /var/run/nginx.pid;   #指定pid的存放位置
error_log  /var/log/nginx_error.log; #指定error.log的位置
events {
        use epoll;
        worker_connections  1024;
}

http {
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffers 4 256k;
fastcgi_buffer_size 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

send_timeout 60;
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;

#开启Gzip压缩大幅提高页面加载速度
gzip on;
#不压缩临界值,大于1K的才压缩,一般不用改
gzip_min_length  1k;
#buffer,就是,嗯,算了不解释了,不用改
gzip_buffers     4 32k;
#用了反向代理的话,末端通信是HTTP/1.0,有需求的应该也不用看我这科普文了;有这句的话注释了就行了,默认是HTTP/1.1
gzip_http_version 1.1;
#压缩级别,1-10,数字越大压缩的越好,时间也越长,看心情随便改吧
gzip_comp_level 2;
#进行压缩的文件类型,缺啥补啥就行了,JavaScript有两种写法,最好都写上吧,总有人抱怨js文件没有压缩,其实多写一种格式就行了
gzip_types   text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
#跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding",我不需要这玩意,自己对照情况看着办吧
gzip_vary on;
#IE6对Gzip不怎么友好,不给它Gzip了
gzip_disable "MSIE [1-6].";
proxy_buffering off;

server_names_hash_bucket_size 128;
client_max_body_size     600m; 
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
#access_log   on;   
include   /etc/nginx/vhosts.conf; 
}

vhosts.conf

server {
        listen       80;
        server_name  192.168.10.1;
        charset utf-8;
        root  /mnt/sda2/www/cc;
        index  index.html index.htm index.php default.php /_h5ai/public/index.php;
        error_page   500 502 503 504  /50x.html;

        if (!-e $request_filename) {
         rewrite ^/index.php(.*)$ /b/index.php?s=$1 last;
         rewrite ^(.*)$ /b/index.php?s=$1 last;
         break;
         }
        #location / {
            #index  index.html index.htm index.php;
            #autoindex  on;
            #try_files $uri $uri/ /index.php$args;
            #try_files $uri $uri/ /index.php$is_args$args;
            #try_files $uri $uri /index.php$query_string;
        #}       
        location /down {
           proxy_pass http://192.168.0.1/down; #或者是root /home/project/docs/
           add_header Content-Disposition: 'attachment;';
           ##index index.php index.html;
           }
        location = /50x.html {
        root html;
        }

        location ~* ^.+\.php(\/.*)*$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        #客户端上传文件大小设为100M
        client_max_body_size 200m;
        #设置临时目录
        client_body_temp_path /mnt/sda2/www/nginx_temp;
        #include        /mnt/sda1/www/vhost/gitblog/.htaccess;
    }
}

/etc/nginx/fastcgi_params

if ($request_filename ~* (.*)\.php) {
    set $php_url $1;
}
if (!-e $php_url.php) {
    return 403;
}

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

/etc/lighttpd/lighttpd.conf

server.modules = ( "mod_rewrite", "mod_redirect", "mod_alias", "mod_extforward", "mod_access", "mod_auth", "mod_setenv", "mod_magnet", "mod_flv_streaming", "mod_userdir",  "mod_status", "mod_simple_vhost", "mod_evhost", "mod_secdownload", "mod_cgi", "mod_fastcgi", "mod_scgi", "mod_ssi", "mod_proxy", "mod_cml", "mod_webdav", "mod_evasive", "mod_compress", "mod_usertrack", "mod_expire", "mod_accesslog" )

###下面的模块是自动加入的,不要手工加入它们:"mod_indexfile", "mod_dirlisting","mod_staticfile","mod_trigger_b4_dl",

server.document-root        = "/mnt/sda2/www/cc"
server.name                 = "ccn.cc"
server.upload-dirs          = ( "/mnt/sda2/www/tmp" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "http"
server.groupname            = "www-data"

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                                "index.lighttpd.html","/_h5ai/public/index.php" )


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

server.port = 80
server.tag = "lighttpd/1.4.38 - Palapa Web Server (http://alfanla.com)"
fastcgi.map-extensions = ( ".php3" => ".php", ".php4" => ".php", ".php5" => ".php" )
fastcgi.server = (
    ".php" => ((
        "host" => "127.0.0.1",
        "port" => 9000,
        "bin-path" => "/usr/bin/spawn-fcgi",
        "bin-environment" => (
            "PHP_FCGI_CHILDREN" => "0",
            "PHP_FCGI_MAX_REQUESTS" => "10000",
            "TMPDIR" => "/mnt/sda2/www/tmp/"
        ),
        "min-procs" => 1,
        "max-procs" => 1,
        "idle-timeout" => 20
    ))
)


### Options that are useful but not always necessary:
#server.chroot               = "/"
#server.port                 = 81
#server.bind                 = "localhost"
#server.tag                  = "lighttpd"
#server.errorlog-use-syslog  = "enable"
#server.network-backend      = "write"

### Use IPv6 if available
#include_shell "/usr/share/lighttpd/use-ipv6.pl"

#dir-listing.encoding        = "utf-8"
#server.dir-listing          = "enable"

include       "/etc/lighttpd/mime.conf"
#include_shell "cat /etc/lighttpd/conf.d/*.conf"

url.rewrite-if-not-file=(
#不重写/sysman,/file目录的防问
#"^/(sysman|file|uploads)(/.*)*" =>"$0" ,
#"/(.*).(.*)" => "$0" ,
"^/(_b/theme/questplus)(/.*)*" =>"$0" ,
#实现thinkphp中index.php的隐藏
"^/_b/(.*)$" => "/_b/index.php/$1" 
)

$HTTP["host"] == "aa.cc"  {
server.document-root        = "/mnt/sda2/www/aa"
server.name                 = "aa.cc"
index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                                "index.lighttpd.html","/_h5ai/public/index.php" )                            
                                }
$HTTP["host"] == "bb.cc"  {
server.document-root        = "/mnt/sda2/www/bb"
server.name                 = "bb.cc"
index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                                "index.lighttpd.html","/_h5ai/public/index.php" )                            
                                }
$HTTP["host"] == "dd.cc"  {
server.document-root        = "/mnt/sda2/www/dd"
server.name                 = "dd.cc"
index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                                "index.lighttpd.html","/_h5ai/public/index.php" )                            
                                }
$HTTP["host"] == "ee.cc"  {
server.document-root        = "/mnt/sda2/www/ee"
server.name                 = "ee.cc"
index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                                "index.lighttpd.html","/_h5ai/public/index.php" )                            
                                }