xref: /lighttpd1.4/doc/scripts/spawn-php.sh (revision ac087bd9)
1#!/bin/bash
2
3## ABSOLUTE path to the spawn-fcgi binary
4SPAWNFCGI="/home/weigon/projects/spawn-fcgi/src/spawn-fcgi"
5
6## ABSOLUTE path to the PHP binary
7FCGIPROGRAM="/usr/local/bin/php"
8
9## TCP port to which to bind on localhost
10FCGIPORT="1026"
11
12## number of PHP children to spawn
13PHP_FCGI_CHILDREN=10
14
15## maximum number of requests a single PHP process can serve before it is restarted
16PHP_FCGI_MAX_REQUESTS=1000
17
18## IP addresses from which PHP should access server connections
19FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.2.10"
20
21# allowed environment variables, separated by spaces
22ALLOWED_ENV="ORACLE_HOME PATH USER"
23
24## if this script is run as root, switch to the following user
25USERID=wwwrun
26GROUPID=wwwrun
27
28
29################## no config below this line
30
31if test x$PHP_FCGI_CHILDREN = x; then
32  PHP_FCGI_CHILDREN=5
33fi
34
35export PHP_FCGI_MAX_REQUESTS
36export FCGI_WEB_SERVER_ADDRS
37
38ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
39
40if test x$UID = x0; then
41  EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN"
42else
43  EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN"
44fi
45
46# copy the allowed environment variables
47E=
48
49for i in $ALLOWED_ENV; do
50  E="$E $i=${!i}"
51done
52
53# clean the environment and set up a new one
54env - $E $EX
55