10月 162010
 

DBばっかり弄っていてもつまらないからCGIを動かすよ ;-)

nginxには欠かせない wrap デーモンをこしらえるゾ :razz:

・材料
fcgi-2.4.0.tar.gz
spawn-fcgi-1.6.3.tar.gz
autoconf-2.61.tar.gz
fcgiwrap-1.0.3.tar.gz

ちょっとばかり面倒だけどがんばろう :!:
では早速…

fcgiはこんな感じ
tar zxf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./ \
'--prefix=/usr/local/fcgi' \
'--enable-static=yes' \
'--enable-shared=yes' \
'--with-pic' \
make
sudo make install

おつぎはspawn-fcgiだね
tar zxf -1.6.3.tar.gz
cd spawn-fcgi-1.6.3
./configure \
'--prefix=/usr/local/spawn-fcgi' \
'--enable-ipv6' \
'--enable-extra-warnings' \
make
sudo make install

ここでautoconfを…
tar zxf autoconf-2.61.tar.gz
cd autoconf-2.61
./configure \
'--prefix=/usr/local/autoconf' \
make
sudo make install

最後にfcgiwrap
tar zxf -1.0.3.tar.gz
cd gnosek-fcgiwrap-58ec209
export PATH=/usr/local/autoconf/bin:$PATH
autoreconf -i
CC="gcc44" CFLAGS="-O3 -fpic -march=native -msse3 -msse4 -msse4.1 -msse4.2 -mfpmath=sse" \
CFLAGS+="-L/usr/local/fcgi/lib/ -I/usr/local/fcgi/include/" \
./configure \
'--prefix=/usr/local/fcgiwrap' \
make
sudo make install

起動スクリプトを作って…
vi /etc/init.d/fcgiwrap
#!/bin/sh
#
# Startup script for the server.
#
# chkconfig: 3 85 15
# description: FastCGI Demon
# processname: fcgiwrap
# Source function library.
. /etc/rc.d/init.d/functions

FCGI_DAEMON=/usr/local/spawn-fcgi/bin/spawn-fcgi
FCGI_PROGRAM=/usr/local/fcgiwrap/sbin/fcgiwrap
FCGI_PIDFILE=/var/run/fcgiwrap.pid
FCGI_SOCKET=/var/run/httpd/fcgiwrap.sock
FCGI_SOCKMODE=0666
FCGI_USER=httpd
FCGI_GROUP=httpd
FCGI_CHILDREN=1

prog=fcgiwrap
lockfile=/var/lock/subsys/$prog

RETVAL=0

start() {
echo -n $"Starting $prog: "
daemon $FCGI_DAEMON -f $FCGI_PROGRAM -s $FCGI_SOCKET -U $FCGI_USER -G $FCGI_GROUP -M $FCGI_SOCKMODE -u $FCGI_USER -P $FCGI_PIDFILE -F $FCGI_CHILDREN
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
rm -f $FCGI_PIDFILE $FCGI_SOCKET
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/$prog ]; then
stop
start
fi
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
RETVAL=1
esac

exit $RETVAL

.confにこんな感じで追加する
fastcgi_pass unix:/var/run/httpd/fcgiwrap.sock;
fastcgi_index index.cgi;
fastcgi_read_timeout 5m;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;

これでとりあえずはいけるっしょ :?:

現在コメント投稿は停止しております。