From owner-freebsd-questions@FreeBSD.ORG Sat Jul 28 03:15:01 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9A5A16A41A for ; Sat, 28 Jul 2007 03:15:01 +0000 (UTC) (envelope-from mkhitrov@gmail.com) Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.189]) by mx1.freebsd.org (Postfix) with ESMTP id 81E1B13C468 for ; Sat, 28 Jul 2007 03:15:01 +0000 (UTC) (envelope-from mkhitrov@gmail.com) Received: by rv-out-0910.google.com with SMTP id f1so124283rvb for ; Fri, 27 Jul 2007 20:15:01 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=jGWko6X/I2h/ELOaA+oKAGjuk4Ft36LdXF9UssRUtenfHL3cuDPYrhKD3C5zRk1Lc3qQC1VRASCiwiikOc35eggRCKd5mKPoQMqxjijNnoe3+3cWqEllx8IfvH2kisVkNPTC1HsBQIOtRuRCT3x7Lads9cQ2ZyMEkQ54R4ehleg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=f6G0TyeLumuaCsE6CjpEJ4DtYncKqzFAORhqQkV6QkvHhnz8RDB58SPKOTRJqQ1MEOvGakdWnt+c9Qud+xVWrki6f9IhBuGJnYOG7+Ge6cj8g+VZsCpKsT+EJBIziWRXeernndOxJ61RJhG91CyKC6eD96W95TjCmPtY1HYyHec= Received: by 10.142.97.20 with SMTP id u20mr204182wfb.1185592501076; Fri, 27 Jul 2007 20:15:01 -0700 (PDT) Received: by 10.143.10.17 with HTTP; Fri, 27 Jul 2007 20:15:01 -0700 (PDT) Message-ID: <26ddd1750707272015g118e7e43ud29d7d0e964a564a@mail.gmail.com> Date: Fri, 27 Jul 2007 23:15:01 -0400 From: "Maxim Khitrov" To: freebsd-questions@freebsd.org In-Reply-To: <26ddd1750707250825t7e4c7ac0g3378038f613fbe3d@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <26ddd1750707241722r24d3aa31ua9c1b92368149e9b@mail.gmail.com> <26ddd1750707250825t7e4c7ac0g3378038f613fbe3d@mail.gmail.com> Subject: Re: FastCGI PHP does not start on server reboot (via rc script). X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jul 2007 03:15:01 -0000 On 7/25/07, Maxim Khitrov wrote: > On 7/24/07, Maxim Khitrov wrote: > > Hello, > > > > I have this problem that I can't figure out. One of my web servers is > > using a combination of lighttpd and FastCGI php to run a few sites. On > > lighttpd website there is an rc script to help FreeBSD users start > > FastCGI php processes automatically. I've pasted that script below. > > > > I should say that if I run it manually as root, everything works > > beautifully. As you can see, the script creates a unix socket at > > /var/run/fastcgi/php.sock, and lighttpd is then able to execute php > > scripts. The problem is that every time the server is rebooted, the > > script does not start back up. I have to start it manually. I can't > > find any log entries that would indicate a problem, so I'm not even > > sure where to start looking. Below is the script that I'm trying to > > run, file permissions for relevant files, and contents of my rc.conf. > > > > Would greatly appreciate it if someone could at least tell me where to > > start looking for a solution to this problem. > > > > Thanks, > > Maxim Khitrov > > > > /etc/rc.conf: > > fcgiphp_enable="YES" > > > > /var/run/fastcgi: > > -rw-r--r-- 1 www www - 5B Jul 24 17:06 php.pid > > srwxr-xr-x 1 www www - 0B Jul 24 17:06 php.sock= > > > > /usr/local/etc/rc.d: > > -r-xr-xr-x 1 root wheel - 1.6K May 23 17:28 fastcgi-php* > > > > /usr/local/etc/rc.d/fastcgi-php: > > #!/bin/sh > > # FreeBSD rc.d script for fastcgi+php > > # in rc.conf > > # fcgiphp_enable (bool): Set it to "YES" to enable fastcgi+php > > # Default is "NO". > > # other options see below > > # > > > > . /etc/rc.subr > > > > name="fcgiphp" > > rcvar=`set_rcvar` > > > > load_rc_config $name > > > > : ${fcgiphp_enable="NO"} > > : ${fcgiphp_bin_path="/usr/local/bin/php-cgi"} > > : ${fcgiphp_user="www"} > > : ${fcgiphp_group="www"} > > : ${fcgiphp_children="2"} > > : ${fcgiphp_port="8002"} > > : ${fcgiphp_socket="/var/run/fastcgi/php.sock"} > > : ${fcgiphp_env="SHELL PATH USER"} > > : ${fcgiphp_max_requests="100"} > > : ${fcgiphp_addr="localhost"} > > > > > > pidfile=/var/run/fastcgi/php.pid > > procname="${fcgiphp_bin_path}" > > command_args="/usr/local/bin/spawn-fcgi 2> /dev/null -f > > ${fcgiphp_bin_path} -u ${fcgiphp_user} -g ${fcgiphp_group} -C > > ${fcgiphp_children} -P ${pidfile}" > > start_precmd=start_precmd > > stop_postcmd=stop_postcmd > > > > start_precmd() > > { > > PHP_FCGI_MAX_REQUESTS="${fcgiphp_max_requests}" > > FCGI_WEB_SERVER_ADDRS=$fcgiphp_addr > > export PHP_FCGI_MAX_REQUESTS > > export FCGI_WEB_SERVER_ADDRS > > allowed_env="${fcgiphp_env} PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS" > > # copy the allowed environment variables > > E="" > > for i in $allowed_env; do > > eval "x=\$$i" > > E="$E $i=$x" > > done > > command="env - $E" > > > > if [ -n "${fcgiphp_socket}" ]; then > > command_args="${command_args} -s ${fcgiphp_socket}" > > elif [ -n "${fcgiphp_port}" ]; then > > command_args="${command_args} -p ${fcgiphp_port}" > > else > > echo "socket or port must be specified!" > > exit > > fi > > } > > > > stop_postcmd() > > { > > rm -f ${pidfile} > > # eval "ipcs | awk '{ if (\$5 == \"${fcgiphp_user}\") print \"ipcrm -s > > \"\$2}' | /bin/sh" > > } > > > > run_rc_command "$1" > > > > Sorry for replying to myself, but I forgot to mention that this server > is actually running inside a jail. I have no idea if that has anything > to do with it. I also have other services being started from > /usr/local/etc/rc.d (lighttpd, mysql, and a few others), but this > fastcgi script is the only one that fails to work. > One other thing to add... I moved the script from /usr/local/etc/rc.d/ to /etc/rc.d/ and it works perfectly. Didn't change a thing other than where the script is running from. All my rc scripts in /etc are also unmodified. Is it really the case that no one has seen something like this before? Why would a script run from one location, but not from another? Especially given the fact that other scripts in /usr/local/etc/rc.d are being executed normally.