Re: Nginx + FastCGI + PHP5 on FreeBSD 6.2



Peter Pluta wrote:

If anyone has a better method of getting it to work please do share it. I'd
like to get it to work and possibly write a small guide aim'd at FreeBSD
users.

nginx.conf snippet:

server {
listen *:80;
server_name ...;
root ...;
access_log /var/log/nginx/....access.log;
index index.php;

location ~ .*\.php$ {
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_pass unix:/tmp/.fastcgi.www/socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME ...$fastcgi_script_name;
}
}

/usr/local/etc/rc.d/phpFcgid script:

#!/bin/sh

# PROVIDE: phpFcgid
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="phpFcgid"
rcvar=`set_rcvar`

load_rc_config $name
: ${phpFcgid_enable="NO"}
: ${phpFcgid_users="www"}
: ${phpFcgid_children="2"}

start_cmd=phpFcgid_start
stop_cmd=phpFcgid_stop

phpFcgid_start() {
echo "Starting $name."
export PHP_FCGI_CHILDREN=${phpFcgid_chidlren}
for user in ${phpFcgid_users}; do
socketdir="/tmp/.fastcgi.${user}"
mkdir -p ${socketdir}
chown ${user}:www ${socketdir}
chmod 0750 ${socketdir}
su -m ${user} -c "/usr/local/bin/php-cgi -b ${socketdir}/socket&"
done
}

phpFcgid_stop() {
echo "Stopping $name."
pids=`pgrep php-cgi`
pkill php-cgi
wait_for_pids $pids
}

run_rc_command "$1"

Also put this to your /etc/rc.conf file:

phpFcgid_enable='yes'

--
Sphinx of black quartz judge my vow.

_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Nginx + FastCGI + PHP5 on FreeBSD 6.2
    ... root ...; ... # PROVIDE: phpFcgid ... echo "Starting $name." ...
    (freebsd-questions)
  • Re: Simple Networking Question?
    ... > Matt Humphrey wrote: ... > #echo stream tcp nowait root internal ... > When you request a web page from a server you're connecting ...
    (comp.lang.java.programmer)
  • Re: Nginx + FastCGI + PHP5 on FreeBSD 6.2
    ... Volodymyr Kostyrko-2 wrote: ... root ...; ... echo "Starting $name." ...
    (freebsd-questions)
  • Missing file utf8 ???
    ... I have a problem with the FC3 server. ... After log in the server as root ... there was an echo on the screen ie: ... KDSKBENT: in valid argument ...
    (Fedora)
  • Re: X server
    ... I dont' know how to determine whether X server is running. ... As root, ... # echo $PATH ... I need to install oracle in the system, thus X server need to be ...
    (comp.unix.solaris)