php_fcgi 647 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # This file a part of SHM. Copyright (C) Tom Li 2013.
  3. # License: LGPL version 3 or later.
  4. USERNAME=$1
  5. DOMAIN=$2
  6. read -r -d '' CONF << EOF
  7. #!/sbin/runscript
  8. depend() {
  9. need net
  10. use nginx
  11. }
  12. start() {
  13. su ${USERNAME} -c 'PHPRC=/home/${USERNAME}/etc/php5 PHP_FCGI_CHILDREN=2
  14. /usr/bin/php-loop.pl /usr/bin/php-cgi -b /var/run/virtualhost/php-${DOMAIN}.sock >> /home/${USERNAME}/logs/php.log 2>&1 </dev/null &
  15. echo \$! >/var/php-nginx/${DOMAIN}.php.pid'
  16. }
  17. stop() {
  18. su ${USERNAME} -c 'kill \`cat /var/php-nginx/${DOMAIN}.php.pid\` ; sleep 1'
  19. }
  20. EOF
  21. echo "$CONF"