nginx 启动 fastcgi 出错

nginx 启动 fastcgi 出错

我收到此错误:

启动服务:spawn-fcgi:绑定失败:地址已在使用中

运行此命令时:

/etc/init.d/phpfcgi 启动

有人能告诉我如何修复它吗?

这是我的 CGI 脚本:

#!/bin/bash
#
# Startup script for the PHP FastCGI server.
#
# chkconfig: 345 85 15
# description: PHP is an HTML-embedded scripting language
# processname: php
# config: /etc/php.ini

# Source function library.
. /etc/rc.d/init.d/functions

SPAWNFCGI="/usr/bin/spawn-fcgi" 
PHPFCGI="/usr/bin/php-cgi"
FCGIPORT="9000"
FCGIADDR="127.0.0.1"
PHP_FCGI_CHILDREN=5
PHP_FCGI_MAX_REQUESTS=1000
ALLOWED_ENV="PATH USER"
USER=nginx
GROUP=nginx
#PHPUSER=php
PIDFILE=/var/run/phpfcgi.pid

if [ -z "$PHP_FCGI_CHILDREN" ]; then
  PHP_FCGI_CHILDREN=5
fi

ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"

case "$1" in
  start)
        PHPFCGI_START=$"Starting ${NAME} service: "
        echo -n $PHPFCGI_START

        # check for $PHPUSER, create if non-existent
        if [ -z "`id -u $PHPUSER 2> /dev/null`" ]; then
            useradd -s /sbin/nologin $PHPUSER
        fi

        # clean environment
        E=
        for i in $ALLOWED_ENV; do E="$E $i=${!i}"; done
        #daemon --user $PHPUSER --pidfile $PIDFILE "env - $E $PHPFCGI -q -b $FCGIADDR:$FCGIPORT &> /dev/null &"
    daemon $SPAWNFCGI -a ${FCGIADDR} -p ${FCGIPORT} -u ${USER} -g ${GROUP} -P ${PIDFILE} -C ${PHP_FCGI_CHILDREN} -f ${PHPFCGI}
    retval=$?

        #pid=`pidof php-cgi`
        #if [ -n "$pid" ]; then
        #    echo $pid > $PIDFILE
        #    success $PHPFCGI_START
        #else
        #    failure $PHPFCGI_START
        #fi
        #echo
        ;;
  stop)
        echo -n "Stopping php-fcgi: "
        killproc -p $PIDFILE phpfcgi
        echo
        ;;
  status)
        status phpfcgi
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
esac

exit 0

答案1

“地址已在使用中”意味着您有另一个进程已经持有该套接字。

您可以使用 netstat 识别其 PID,使用方法为(以 root 身份):

netstat -tpan |grep "LISTEN"|grep :9000

最后一栏给你PID/进程名称. 只需做一个杀死-9 PID

相关内容