diff options
Diffstat (limited to '~fauno/spawn-fcgi-php')
-rw-r--r-- | ~fauno/spawn-fcgi-php/PKGBUILD | 40 | ||||
-rw-r--r-- | ~fauno/spawn-fcgi-php/nginx.conf.example | 34 | ||||
-rw-r--r-- | ~fauno/spawn-fcgi-php/public_html.conf.example | 16 | ||||
-rw-r--r-- | ~fauno/spawn-fcgi-php/server.conf.example | 22 | ||||
-rwxr-xr-x | ~fauno/spawn-fcgi-php/spawn-fcgi-php | 460 | ||||
-rw-r--r-- | ~fauno/spawn-fcgi-php/spawn-fcgi-php.conf | 60 |
6 files changed, 0 insertions, 632 deletions
diff --git a/~fauno/spawn-fcgi-php/PKGBUILD b/~fauno/spawn-fcgi-php/PKGBUILD deleted file mode 100644 index a49858417..000000000 --- a/~fauno/spawn-fcgi-php/PKGBUILD +++ /dev/null @@ -1,40 +0,0 @@ -# Contributor: Piotr Rogoża <rogoza dot piotr at gmail dot com> -pkgname=spawn-fcgi-php -pkgver=1.1.1 -pkgrel=1 -pkgdesc="script to provide simple cgi-php support for nginx http daemon" -arch=('any') -url="http://aur.archlinux.org/packages.php?ID=37439" -license=('GPL') -depends=('php-cgi' 'spawn-fcgi') -backup=('etc/conf.d/spawn-fcgi-php.conf') -source=( - 'spawn-fcgi-php' - 'spawn-fcgi-php.conf' - 'server.conf.example' - 'nginx.conf.example' - 'public_html.conf.example' -) - -build() { - # Install script and configuration file - install -Dm775 spawn-fcgi-php \ - ${pkgdir}/etc/rc.d/spawn-fcgi-php || return 1 - install -Dm664 spawn-fcgi-php.conf \ - ${pkgdir}/etc/conf.d/spawn-fcgi-php.conf || return 1 - - # Install examples of configuration - install -Dm664 public_html.conf.example \ - ${pkgdir}/etc/nginx/conf/public_html.conf.example || return 1 - install -Dm644 server.conf.example \ - ${pkgdir}/etc/nginx/conf/server.conf.example || return 1 - install -Dm664 nginx.conf.example \ - ${pkgdir}/etc/nginx/conf/nginx.conf.example || return 1 -} - -# vim:set ts=2 sw=2 et ft=sh: -md5sums=('9088c130caebf43902f958c985200811' - 'a8bfb0b50120c91449c8a08144706c9b' - 'c02189e88531386cd67d3401924c18ae' - '00bf49fc8a0d8c9f6c96305fae8471d4' - '9202545dc3701d5933804890312667e6') diff --git a/~fauno/spawn-fcgi-php/nginx.conf.example b/~fauno/spawn-fcgi-php/nginx.conf.example deleted file mode 100644 index 35d0868f3..000000000 --- a/~fauno/spawn-fcgi-php/nginx.conf.example +++ /dev/null @@ -1,34 +0,0 @@ -user http; -worker_processes 1; - -error_log logs/error.log; - -#pid logs/nginx.pid; - -events { - worker_connections 1024; -} - - -http { - include mime.types; - default_type application/octet-stream; - - sendfile on; - #tcp_nopush on; - - #keepalive_timeout 0; - keepalive_timeout 65; - - #gzip on; - - # the file with mapping username per port - include /etc/nginx/conf/map_user2port.conf; - #or only - #include map_user2port.conf - - # Servers configurations ... - include server.conf.example; - - } -} diff --git a/~fauno/spawn-fcgi-php/public_html.conf.example b/~fauno/spawn-fcgi-php/public_html.conf.example deleted file mode 100644 index 74f6c2b4b..000000000 --- a/~fauno/spawn-fcgi-php/public_html.conf.example +++ /dev/null @@ -1,16 +0,0 @@ -location ~ ^/~([^/]+)(/?.*)$ { - set $username $1; - alias /home/$1/public_html/$2; - autoindex on; - location ~ \.php { - #fastcgi_pass 127.0.0.1:9000; - # or for multiusers, one port per user - fastcgi_pass 127.0.0.1:$port; - # or for unix domain sockets - #fastcgi_pass unix:/var/run/spawn-fcgi/spawn-fcgi.$username.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include /etc/nginx/conf/fastcgi_params; - } -} -# vi: ft=nginx diff --git a/~fauno/spawn-fcgi-php/server.conf.example b/~fauno/spawn-fcgi-php/server.conf.example deleted file mode 100644 index 06160cfb2..000000000 --- a/~fauno/spawn-fcgi-php/server.conf.example +++ /dev/null @@ -1,22 +0,0 @@ -server { - listen 80; - server_name domain.tld; - root /srv/http/domain.tld; - - index index.php index.html; - - access_log logs/access.log; - error_log logs/error.log; - - location ~ \.php { - # TCP - fastcgi_pass 127.0.0.1:9000; - # or SOCKET - #fastcgi_pass unix:/var/run/spawn-fcgi/spawn-fcgi.sock; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include /etc/nginx/conf/fastcgi_params; - } - include public_html.conf.example; -} -# vi: ft=nginx diff --git a/~fauno/spawn-fcgi-php/spawn-fcgi-php b/~fauno/spawn-fcgi-php/spawn-fcgi-php deleted file mode 100755 index 607ebab8c..000000000 --- a/~fauno/spawn-fcgi-php/spawn-fcgi-php +++ /dev/null @@ -1,460 +0,0 @@ -#!/bin/bash - -. /etc/rc.conf -. /etc/rc.d/functions - -NAME=spawn-fcgi-php -CONF="/etc/conf.d/spawn-fcgi-php.conf" -#------------------------------------------------------------------------------- -# Return value for: -# for check_process -PROCNOPIDEXIST=-1 # none process is running and pidfile exist -PROCNOPIDNO=0 # none process is running -PROCRUNPIDEXIST=1 # process is running, pidfile exist and has size >0b -PROCRUNPID0=2 # process is running, pidfile has size 0b -PROCRUNPIDNO=3 # process is running, pidfile doesn't exist -OTHERERROR=255 -# check_daemon -DAEMONEXIST=0 -DAEMONNOEXIST=1 -#------------------------------------------------------------------------------- - -# Reading configuration -if [ -r "$CONF" ]; then - . $CONF -else - stat_fail - stat_busy "File $CONF not found" - stat_die -fi -check_config(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: check_config -# DESCRIPTION: Check configuration file -# PARAMETERS: -# RETURNS: 0 if all right -#=============================================================================== - # testing DAEMON - if [ ! -x "$DAEMON" ]; then - stat_fail - stat_busy "File $DAEMON isn't executable" - stat_die - fi - # testing USER and GROUP - if [ -z "$USER" -o -z "$GROUP" ]; then - stat_fail - stat_busy "The variable USER/GROUP isn't defined. I cann't run process $PHPCGI as root." - stat_die - fi - # testing directory of socket - if [ -n "$SOCKET" ]; then - local sockdir=$(dirname "$SOCKET") - if [ ! -d "$sockdir" ]; then - mkdir -p "$sockdir" - fi - fi - # testing directory for user's socket - if [ -n "$USERSOCKET" ]; then - local socksdir=$(dirname "$USERSOCKET") - if [ ! -d "$socksdir" ]; then - mkdir -p "$socksdir" - fi - fi - # testing directory of pidfile - if [ -n "$PIDFILE" ]; then - if [ ! -d $(dirname $PIDFILE) ]; then - mkdir -p $(dirname $PIDFILE) - fi - fi - # testing the program php-cgi - if [ -z "$PHPCGI" ]; then - stat_fail - stat_busy "The variable PHPCGI isn't defined" - stat_die - else - if [ ! -x "$PHPCGI" ]; then - stat_fail - stat_busy "The program $PHPCGI isn't executable" - stat_die - fi - fi - return 0 -} #}}} -check_process(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: check_process -# DESCRIPTION: Check that process is alive -# PARAMETERS: name of process and/or pidfile -# RETURNS: look at the beginning of the script -#=============================================================================== - local process - local pidfile - if [ $# -eq 2 ]; then - process=$1 - pidfile=$2 - elif [ $# -eq 1 ]; then - process=$1 - else - return $OTHERERROR - fi - - if get_pid $process >/dev/null; then - # process is running - if [ -s "$pidfile" ]; then - return $PROCRUNPIDEXIST - elif [ -r "$pidfile" ]; then - return $PROCRUNPID0 - else - return $PROCRUNPIDNO - fi - else - # process doesn't runnig - if [ -r "$pidfile" ]; then - return $PROCNOPIDEXIST - else - return $PROCNOPIDNO - fi - fi -} #}}} -get_userpid(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: get_userpid -# DESCRIPTION: looking for pid of process belong to user -# PARAMETERS: name of user, name of process -# RETURNS: pid of process or 1 if error -#=============================================================================== - local user=$1 - local process=$2 - if [ -n "$user" -a -n "$process" ]; then - local pid=$(ps aux | \ - awk -vuser=$user -vprocess=$process \ - '$1 == user && $8 ~ "s" && $11 == process {print $2}') - if [[ "$pid" =~ ^[0-9]+$ ]]; then - echo $pid - else - return 1 - fi - else - return 1 - fi -} #}}} -check_daemon(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: check_daemon -# DESCRIPTION: check that daemon exist in directory -# PARAMETERS: name of daemon -# RETURNS: look at the beginning of the script -#=============================================================================== - if ck_daemon $NAME; then - return $DAEMONEXIST - else - return $DAEMONEXIST - fi -} #}}} -start(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: start -# DESCRIPTION: check configuration, if a process is already running and running php-cgi daemon -# PARAMETERS: - -# RETURNS: - -#=============================================================================== - stat_busy "Checking configuration" - check_config && - stat_done || \ - stat_die - - stat_busy "Starting server $NAME" #{{{ - check_process $PHPCGI $PIDFILE - local error=$? - if [ $error -ge $PROCRUNPIDEXIST -a $error -le $PROCRUNPIDNO ]; then - stat_fail - case $error in - $PROCRUNPIDEXIST) - stat_busy "The process $PHP is running" - ;; - $PROCRUNPID0) - stat_busy "The process $PHP is running and pidfile has size 0b" - ;; - $PROCRUNPIDNO) - stat_busy "The process $PHP is running and pidfile doesn't exist" - ;; - esac - stat_die $error - elif [ $error -eq $OTHERERROR ]; then - stat_fail - stat_busy "Something went wrong..." - stat_die $returnvalue - fi - - # run the main daemon - $DAEMON $OPTIONS >/dev/null - if [ $? -eq 0 ]; then - add_daemon $NAME - stat_done - else - stat_die - fi - #}}} - #{{{ start daemons for multiusers - if [ -n "$STARTMULTI" ]; then - stat_busy "Starting server $NAME for multiusers" - gen_all_uid - if [ -z "$USERSOCKET" ]; then - # Generate file map user 2 port - :>$MAPUSER2PORT - cat >> $MAPUSER2PORT <<- EOF - # Map username to port - map \$username \$port { - default $PORT; - - EOF - local userport=$PORT - local uid - for uid in ${ALLUID[@]}; do - local login=$(uid2login $uid) - if [ $? -eq 0 ]; then - userport=$((userport+1)) - echo -e "$login $userport;" >> $MAPUSER2PORT - local gid=$(id -g $login) - local group=$(gid2group $gid) - if [ -n "$USERPIDFILE" ]; then - local userpidfile=${USERPIDFILE}.${login}.pid - fi - USEROPTIONS="-a $IPADDR -p $userport -u $login ${group:+-g $group} -f $PHPCGI -C ${USER_PHP_FCGI_CHILDREN:-1} ${userpidfile:+-P $userpidfile}" - $DAEMON $USEROPTIONS &>/dev/null - if [ $? -ne 0 ]; then - stat_die - fi - fi - done - echo '}' >> $MAPUSER2PORT - stat_done - elif [ -n "$USERSOCKET" ]; then - local uid - for uid in ${ALLUID[@]}; do - local login=$(uid2login $uid) - if [ $? -eq 0 ]; then - local gid=$(id -g $login) - local group=$(gid2group $gid) - if [ -n "$USERPIDFILE" ]; then - local userpidfile=${USERPIDFILE}.${login}.pid - fi - local usersocket=${USERSOCKET}.${login}.sock - USEROPTIONS="-s ${usersocket} -u $login ${group:+-g $group} -f $PHPCGI -C ${USER_PHP_FCGI_CHILDREN:-1} ${userpidfile:+-P $userpidfile}" - $DAEMON $USEROPTIONS &>/dev/null - if [ $? -ne 0 ]; then - stat_die - fi - fi - done - stat_done - fi - fi - #}}} -} #}}} -stop(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: stop -# DESCRIPTION: check whether a process is running, stop the daemon php-cgi -# PARAMETERS: - -# RETURNS: - -#=============================================================================== - stat_busy "Stopping server $NAME" #{{{ - # for main daemon - if ! get_pid $PHPCGI &>/dev/null; then - stat_fail - stat_busy "None process $PHPCGI isn't running" - stat_die - else - #process php-cgi is running - if [ -s "$PIDFILE" ]; then - # pidfile exists - kill $(<$PIDFILE) - if [ $? -eq 0 ]; then - rm -f $PIDFILE - rm_daemon $NAME - stat_done - else - stat_die - fi - else #pidfile doesn't exist - if [ -r "$PIDFILE" ]; then - #pidfile exists and has size 0b - stat_busy "Pidfile $PIDFILE exists and has size 0b.Removing it" - rm -f "$PIDFILE" && \ - stat_done || \ - stat_fail - fi - killall -9 $PHPCGI - if [ $? -eq 0 ]; then - stat_done - rm_daemon $NAME - else - stat_die - fi - fi - fi - #}}} - #{{{ for multiusers - if [ -n "$STARTMULTI" ]; then - # waiting to kill the main daemon - sleep 1 - if get_pid $PHPCGI &>/dev/null; then - stat_busy "Stopping server $NAME for multiusers" - killall $PHPCGI - # cleaning pidfiles - if [ -n "$USERPIDFILE" ]; then - gen_all_uid - for UserID in ${ALLUID[@]}; do - local login=$(uid2login $UserID) - if [ $? -eq 0 ]; then - rm -f ${USERPIDFILE}.${login}.pid - fi - done - fi #$USERPIDFILE - stat_done - fi - fi - #}}} -} #}}} -restart(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: restart -# DESCRIPTION: stop and start service -# PARAMETERS: - -# RETURNS: - -#=============================================================================== - stat_busy "Restarting server $NAME" - stop - sleep 1 - start -} #}}} -status(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: status -# DESCRIPTION: check status of service -# PARAMETERS: - -# RETURNS: - -#=============================================================================== - if ! get_pid $PHPCGI>/dev/null; then - stat_busy "None process $PHPCGI isn't running" - stat_done - else - stat_busy "Process $PHPCGI is running" - stat_done - if [ -s "$PIDFILE" ]; then - stat_busy "It's spawned by process: $(cat $PIDFILE|tr '\n' ' ')"; - stat_done - elif [ -r "$PIDFILE" ]; then - stat_fail - stat_busy "Pidfile $PIDFILE exists but has size 0b" - else - stat_busy "Pidfile $PIDFILE doesn't exist" - stat_done - fi - if [ -n "$STARTMULTI" -a -n "$USERSSTATUS" ]; then - gen_all_uid - local uid - for uid in ${ALLUID[@]}; do - local login=$(uid2login $uid) - if [ $? -eq 0 ]; then - if [ -n "$USERPIDFILE" ]; then - # USERPIDFILE defined - local userpidfile=${USERPIDFILE}.${login}.pid - if [ -s "$userpidfile" ]; then - stat_busy "Process $PHPCGI of user $login is spawned by process: $(cat $userpidfile|tr '\n' ' ')"; - stat_done - fi - else - local pid=$(get_userpid $login $PHPCGI) - if [ $? -eq 0 ]; then - stat_busy "Process $PHPCGI for user $login is running and it's spawned by: $pid"; - stat_done - fi - fi - fi - done - fi - fi -} #}}} -uid2login(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: uid2login -# DESCRIPTION: convert uid to username -# PARAMETERS: uid -# RETURNS: name of user for uid -#=============================================================================== - local uid=$1 - if [ ! $uid -gt 0 ]; then - return 1 - fi - local username=$(getent passwd | awk -vuid=$uid -F: '$3 == uid {print $1}') - if [ -z "$username" ]; then - return 1 - else - echo $username - fi -} #}}} -gid2group(){ #{{{ - #=== FUNCTION ================================================================ - # NAME: uid2group - # DESCRIPTION: convert gid to name of group - # PARAMETERS: gid - # RETURNS: name of group for gid - #=============================================================================== - local gid=$1 - if [ ! $gid -gt 0 ]; then - return 1 - fi - local groupname=$(getent group | awk -vgid=$1 -F: '$3 == gid {print $1}') - if [ -z "$groupname" ]; then - return 1 - else - echo $groupname - fi -} #}}} -gen_all_uid(){ #{{{ -#=== FUNCTION ================================================================ -# NAME: gen_all_uid -# DESCRIPTION: Generate array of all UID -# PARAMETERS: - -# RETURNS: - -#=============================================================================== - ALLUID=() - if [ -n "$RANGEUID" -a ${#RANGEUID[@]} -gt 0 ]; then - for line in ${RANGEUID[@]/,/ }; do - (( line )) || stat_die # not a number - if [[ ${line/-/} != $line ]]; then - for ((i=${line%-*}; i<=${line#*-}; i++)); do - ALLUID+=($i) - done - else - ALLUID+=($line) - fi - done - elif [ $FIRSTUID -gt 1 -a $LASTUID -gt 1 -a $LASTUID -ge $FIRSTUID ]; then - for ((line=FIRSTUID; line<=LASTUID; line++)); do - (( line )) || stat_die #not a number - ALLUID+=($line) - done - else - echo "Error: Wrong range UID. Change RANGEUID or FIRSTUID and LASTUID" - exit 1 - fi -} #}}} -case $1 in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - status) - status - ;; - *) - echo "Usage: $0 start|stop|restart|status" -esac diff --git a/~fauno/spawn-fcgi-php/spawn-fcgi-php.conf b/~fauno/spawn-fcgi-php/spawn-fcgi-php.conf deleted file mode 100644 index d87520c1d..000000000 --- a/~fauno/spawn-fcgi-php/spawn-fcgi-php.conf +++ /dev/null @@ -1,60 +0,0 @@ -# vi: ft=sh -# run PHPCGI as -USER=http -GROUP=http - -# Name of daemon -DAEMON="/usr/bin/spawn-fcgi" -PIDFILE="/var/run/spawn-fcgi-php.pid" -# spawn the process -PHPCGI="/usr/bin/php-cgi" - -#------------------------------------------------------------------------------- -# Options for php-cgi -#------------------------------------------------------------------------------- -# (PHP only) Number of children to spawn -PHP_FCGI_CHILDREN=4 -# or export PHP_FCGI_CHILDREN -# PHP FastCGI proccess exit after requests: -export PHP_FCGI_MAX_REQUESTS=1000 -# Choose ONE of PORT/IPADDR (for TCP) OR SOCKET (for unix domain sockets) -IPADDR=127.0.0.1 -PORT=9000 -#SOCKET=/var/run/spawn-fcgi/spawn-fcgi.sock -# Options only for socket -#MODE=0644 -#SOCKET_USER=other -#SOCKET_GROUP=other - -#------------------------------------------------------------------------------- -# Options for spawn-fcgi -#------------------------------------------------------------------------------- -# Number of children to fork, defaults to 1. -SPAWN_FCGI_CHILDREN=1 - - -#------------------------------------------------------------------------------- -# For many users -#------------------------------------------------------------------------------- -# Run separate processes for users with UIDs from the range RANGEUID -# uncomment STARTMULTI if you want this -STARTMULTI=yes -# Base user's socket, uncomment to use socket instead IPADDR:USERPORT -USERSOCKET='/var/run/spawn-fcgi/spawn-fcgi' -# file with mapping user to port -MAPUSER2PORT='/etc/nginx/conf/map_user2port.conf' -# Base user's pidfile -#USERPIDFILE='/var/run/spawn-fcgi-php' -# range for UIDs, use the dash for range and split groups by spaces e.g. 1000-1003 1005 1010-1020, use parenthis for all -RANGEUID=(1000-1001) -# (PHP only) Number of children to spawn -USER_PHP_FCGI_CHILDREN=1 -# for status, comment if you don't want print status for users -#USERSSTATUS=yes - -OPTIONS="-u $USER -g $GROUP -f $PHPCGI -C ${PHP_FCGI_CHILDREN:-4} ${PIDFILE:+-P $PIDFILE} -F ${SPAWN_FCGI_CHILDREN:-1} " -if [ -n "$SOCKET" ]; then - OPTIONS+="-s $SOCKET ${MODE:+-M $MODE} ${SOCKET_USER:+-U $SOCKET_USER} ${SOCKET_GROUP:+-G $SOCKET_GROUP} " -else - OPTIONS+="-a $IPADDR -p $PORT " -fi |