write down,forget
adidas eqt support ultra primeknit vintage white coming soon adidas eqt support ultra boost primeknit adidas eqt support ultra pk vintage white available now adidas eqt support ultra primeknit vintage white sz adidas eqt support ultra boost primeknit adidas eqt adv support primeknit adidas eqt support ultra boost turbo red white adidas eqt support ultra boost turbo red white adidas eqt support ultra boost turbo red adidas eqt support ultra whiteturbo adidas eqt support ultra boost off white more images adidas eqt support ultra boost white tactile green adidas eqt support ultra boost beige adidas eqt support ultra boost beige adidas eqt support refined camo drop adidas eqt support refined camo drop adidas eqt support refined running whitecamo adidas eqt support 93 primeknit og colorway ba7506 adidas eqt running support 93 adidas eqt support 93
标签 Tag : ngix

nginx下fastcgi方式运行Perl程序

<Category: Linux> Comments Off on nginx下fastcgi方式运行Perl程序

见鬼了,这篇文章又丢失了,vps的数据难道回滚了,靠。
perl
1.安装FCGI:

2.安装FCGI-ProcManager

3.编辑两个文件

cd /usr/local/nginx/
  ls
  cd sbin/
  ls
  vi cgiwrap-fcgi.pl
  chmod +x cgiwrap-fcgi.pl

4.cgiwrap-fcgi.pl文件内容
#!/usr/bin/perl -w
use FCGI;
use Socket;
use FCGI::ProcManager;
sub shutdown { FCGI::CloseSocket($socket); exit; }
sub restart  { FCGI::CloseSocket($socket); &main; }
use sigtrap ‘handler’, &shutdown, ‘normal-signals’;
use sigtrap ‘handler’, &restart,  ‘HUP’;
require ‘syscall.ph’;
use POSIX qw(setsid);
 
#&daemonize; we don’t daemonize when running under runsv
#this keeps the program alive or something after exec’ing perl scripts
END()   { }
BEGIN() { }
{
    no warnings;
    *CORE::GLOBAL::exit = sub { die “fakeexitnrc=” . shift() . n; };
};
eval q{exit};
if ($@) {
    exit unless $@ =~ /^fakeexit/;
}
&main;
 
sub daemonize() {
    chdir ‘/’ or die “Can’t chdir to /: $!”;
    defined( my $pid = fork ) or die “Can’t fork: $!”;
    exit if $pid;
    setsid() or die “Can’t start a new session: $!”;
    umask 0;
}
 
sub main {
 
#$socket = FCGI::OpenSocket( “127.0.0.1:8999”, 10 ); #use IP sockets
#$socket = FCGI::OpenSocket( “/var/run/nginx/perl_cgi-dispatch.sock”, 10 ); #use UNIX sockets – user running this script must have w access to the ‘nginx’ folder!!
#foreach $item (keys %ENV) { delete $ENV{$item}; }
    $proc_manager = FCGI::ProcManager->new( {n_processes => 5} );
    $socket = FCGI::OpenSocket( “/var/run/fcgi.sock”, 10 )
        ; #use UNIX sockets – user running this script must have w access to the ‘nginx’ folder!!
    $request =
        FCGI::Request( *STDIN, *STDOUT, *STDERR, %req_params, $socket,
        &FCGI::FAIL_ACCEPT_ON_INTR );
    $proc_manager>pm_manage();
    if ($request) { request_loop() }
    FCGI::CloseSocket($socket);
}
 
sub request_loop {
    while ( $request>Accept() >= 0 ) {
        $proc_manager>pm_pre_dispatch();
 
        #processing any STDIN input from WebServer (for CGI-POST actions)
        $stdin_passthrough = ;
        { no warnings; $req_len = 0 + $req_params{‘CONTENT_LENGTH’}; };
        if ( ( $req_params{‘REQUEST_METHOD’} eq ‘POST’ ) && ( $req_len != 0 ) )
        {
            my $bytes_read = 0;
            while ( $bytes_read < $req_len ) {
                my $data = ;
                my $bytes = read( STDIN, $data, ( $req_len$bytes_read ) );
                last if ( $bytes == 0 || !defined($bytes) );
                $stdin_passthrough .= $data;
                $bytes_read += $bytes;
            }
        }
 
        #running the cgi app
        if (
            ( -x $req_params{SCRIPT_FILENAME} ) &&    #can I execute this?
            ( -s $req_params{SCRIPT_FILENAME} ) &&    #Is this file empty?
            ( -r $req_params{SCRIPT_FILENAME} )       #can I read this file?
            )
        {
            pipe( CHILD_RD,   PARENT_WR );
            pipe( PARENT_ERR, CHILD_ERR );
            my $pid = open( CHILD_O, “-|” );
            unless ( defined($pid) ) {
                print(“Content-type: text/plainrnrn);
                print
“Error: CGI app returned no output – Executing $req_params{SCRIPT_FILENAME} failed !n;
                next;
            }
            $oldfh = select(PARENT_ERR);
            $|     = 1;
            select(CHILD_O);
            $| = 1;
            select($oldfh);
            if ( $pid > 0 ) {
                close(CHILD_RD);
                close(CHILD_ERR);
                print PARENT_WR $stdin_passthrough;
                close(PARENT_WR);
                $rin = $rout = $ein = $eout = ;
                vec( $rin, fileno(CHILD_O),    1 ) = 1;
                vec( $rin, fileno(PARENT_ERR), 1 ) = 1;
                $ein    = $rin;
                $nfound = 0;
 
                while ( $nfound =
                    select( $rout = $rin, undef, $ein = $eout, 10 ) )
                {
                    die “$!” unless $nfound != –1;
                    $r1 = vec( $rout, fileno(PARENT_ERR), 1 ) == 1;
                    $r2 = vec( $rout, fileno(CHILD_O),    1 ) == 1;
                    $e1 = vec( $eout, fileno(PARENT_ERR), 1 ) == 1;
                    $e2 = vec( $eout, fileno(CHILD_O),    1 ) == 1;
 
                    if ($r1) {
                        while ( $bytes = read( PARENT_ERR, $errbytes, 4096 ) ) {
                            print STDERR $errbytes;
                        }
                        if ($!) {
                            $err = $!;
                            die $!;
                            vec( $rin, fileno(PARENT_ERR), 1 ) = 0
                                unless ( $err == EINTR or $err == EAGAIN );
                        }
                    }
                    if ($r2) {
                        while ( $bytes = read( CHILD_O, $s, 4096 ) ) {
                            print $s;
                        }
                        if ( !defined($bytes) ) {
                            $err = $!;
                            die $!;
                            vec( $rin, fileno(CHILD_O), 1 ) = 0
                                unless ( $err == EINTR or $err == EAGAIN );
                        }
                    }
                    last if ( $e1 || $e2 );
                }
                close CHILD_RD;
                close PARENT_ERR;
                waitpid( $pid, 0 );
            } else {
                foreach $key ( keys %req_params ) {
                    $ENV{$key} = $req_params{$key};
                }
 
                # cd to the script’s local directory
                if ( $req_params{SCRIPT_FILENAME} =~ /^(.*)/[^/]+$/ ) {
                    chdir $1;
                }
                close(PARENT_WR);
 
                #close(PARENT_ERR);
                close(STDIN);
                close(STDERR);
 
                #fcntl(CHILD_RD, F_DUPFD, 0);
                syscall( &SYS_dup2, fileno(CHILD_RD)0 );
                syscall( &SYS_dup2, fileno(CHILD_ERR), 2 );
 
                #open(STDIN, “<&CHILD_RD”);
                exec( $req_params{SCRIPT_FILENAME} );
                die(“exec failed”);
            }
        } else {
            print(“Content-type: text/plainrnrn);
            print
“Error: No such CGI app – $req_params{SCRIPT_FILENAME} may not exist or is not executable by this process.n;
        }
    }
}

运行脚本


运行下面的命令来查看perl是否运行

5.添加文件

6.Nginx配置

fascgi_params内容如下:

本文来自: nginx下fastcgi方式运行Perl程序

lnmp、mono与asp.net环境安装

<Category: Linux, 小道消息> Comments Off on lnmp、mono与asp.net环境安装

kloxo虽然比较强大,但是太耗资源,有些东西不一定需要,所以决定还是装LNMP。另外需要调试下ASP.NET程序,把MONO也装上了,使用fastcgi、mysql和nginx。

1.安装lnmp

asp.net支持
2.编译安装mono 2.0

3.安装完毕后可以通过“mono -V”查看mono版本

4.安装fastcgi-mono-server

 

下面的方法经测可用
#yum groupinstall Mono
But I noticed the version of Mono I installed is 1.2.4, seems that the lastversion of mono (2.4.2.3) is not in the CentOS package repositories.
Then I tried to find the last version distribution from Mono Home page and google, but no result, So I had to download the source code and compile it all by my self.
After some attempts, I got the following steps to compile and install the last version Mono on my CentOS 5.2 VPS host,
1.prepare the compile environment,
# yum install gcc bison pkgconfig glib2-devel gettext make

2.Go to this page and download the last version Mono(in my case, mono-2.4.2.3.tar.bz2),
#wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.2.3.tar.bz2

3.Extract the downloaded file,
# tar jxvf mono-2.4.2.3.tar.bz2

4.Change to the newly created directory,
# cd mono-2.4.2.3

5.I put my built packages in /opt so, run the following command to build mono,
# ./configure –prefix=/opt/mono; make; make install
6.Update ~/.bash_profile,

#echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
#echo export PATH=/opt/mono/bin:$PATH>>~/.bash_profile
#source ~/.bash_profile

7. Test it,
#mono -V
and I got the output:

Mono JIT compiler version 2.4.2.3 (tarball Thu Oct 22 06:42:24 MSD 2009)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none

Great, I got it.
I think I’d better put all script I used in one place,

mkdir ~/software
yum install gcc bison pkgconfig glib2-devel gettext make
wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.2.3.tar.bz2
tar jxvf mono-2.4.2.3.tar.bz2
cd mono-2.4.2.3
./configure –prefix=/opt/mono; make; make install
echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
echo export PATH=/opt/mono/bin:$PATH>>~/.bash_profile
source ~/.bash_profile
mono -V
cd ..
rm -rf mono-2.4.2.3

references,
Mono Home Page
[HOWTO] Install Mono 2.4 on CentOS 5.3

nginx配置server节点之后
fastcgi-mono-server2 /socket=tcp:9000 &

重启nginx:kill -HUP cat /usr/local/nginx/logs/nginx.pid

asp.net探针截图

本文来自: lnmp、mono与asp.net环境安装