nginx + perl

nginxでperlを動かす。

install FastCGI

$ curl http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz -o fcgi-2.4.0.tar.gz
$ tar xvzf fcgi-2.4.0.tar.gz
$ cd fcgi-2.4.0
$ CFLAGS="-O3 -mtune=native -m64 -msse -msse2 -msse3 -fstrict-overflow -fopenmp" ./configure

libfcgi/fcgio.cpp編集(stdio.hが無いのでmacroがundefinedになる)
$ diff libfcgi/fcgio.cpp.org libfcgi/fcgio.cpp
24a25

$ make && sudo make insatll

ld
$ cat /etc/ld.so.conf.d/fcgi.conf
/usr/local/lib
$ sudo ldconfig ---verbose

install fcgiwrap

http://wiki.nginx.org/Fcgiwrap
http://nginx.localdomain.pl/wiki/FcgiWrap

$ git clone git://github.com/gnosek/fcgiwrap.git
$ cd fcgiwrap/

undefined reference to rpl_malloc対策
ref. http://www.mail-archive.com/pound@apsis.ch/msg00619.html
$ export ac_cv_func_malloc_0_nonnull=yes

$ autoreconf -i
$ CFLAGS="-O3 -mtune=native -m64 -msse -msse2 -msse3 -fstrict-overflow -fopenmp" ./configure
$ make && sudo make install

/etc/init.d/fcgiwrap

$ cat /etc/init.d/fcgiwrap
#!/usr/bin/perl

use strict;
use warnings FATAL => qw( all );

use IO::Socket::UNIX;

my $bin_path = '/usr/local/sbin/fcgiwrap';
my $socket_path = $ARGV[0] || '/tmp/cgi.sock';
my $num_children = $ARGV[1] || 1;

close STDIN;

unlink $socket_path;
my $socket = IO::Socket::UNIX->new(
Local => $socket_path,
Listen => 100,
);

die "Cannot create socket at $socket_path: $!\n" unless $socket;

# 暫定対策
chmod(0777, $socket_path);

for (1 .. $num_children) {
my $pid = fork;
die "Cannot fork: $!" unless defined $pid;
next if $pid;

exec $bin_path;
die "Failed to exec $bin_path: $!\n";
}

$ sudo chmod +x /etc/init.d/fcgiwrap
$ sudo perl /etc/init.d/fcgiwrap

nginx.conf

$ test -e /usr/local/nginx/conf/fastcgi_params || echo error
$ cat /usr/local/nginx/conf/nginx.conf
.
.
server {
.
location / {
root html;
index index.html index.htm index.cgi;
}
.
location ~ \.cgi$
{
fastcgi_pass unix:/tmp/cgi.sock;
fastcgi_read_timeout 5m;
fastcgi_index index.cgi;
include fastcgi_params;
}
.
}
.
.

$ sudo /usr/local/nginx/sbin/nginx -s reload

cpan

$ sudo yum -y install cpan
$ sudo su -
$ cpan
cpan[0] > install CGI
cpan[0] > install YAML

test

fswiki移植完了。

http://psychobil.ly/ciao/