spawn-php.sh 1.3 KB

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