文件:
cgiwrap-fcgi.rar
大小:
1KB
下载:nginx支持cgi-bin && php
先下载一个pcre
不用安装,解压开放一个地方就可以。
编译、安装nginx
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/root/pcre-8.10 --with-http_ssl_module
make
make install
编译、安装php
php.net下载php,解压。
这里需要先下载一个php-fpm,注意其应该对应相同的php版本。
这个是因为php的php-cgi程序,太脆了。
我webbench 试了一下,10个并发就挂了....
然后编译安装php
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/ --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir=/usr/include/freetype2/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mhash;make;install
这些参数是需要一些rpm包支持的。
libjpeg-devel
libpng-devel
libiconv
free-type
libxml
libmcrypt
mcrypt
mhash
大概这些,缺啥补啥。x64位系统需要把生成在/usr/lib64下的lib文件和.h文件cp到/usr下的include或lib下。
若你不需mysql,请删掉--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config部分
cp php.ini-dist /usr/local/php
在nginx里加入php支持,default就自带。把注释去掉,再改点东西就成了。
location ~ \.(php|php5)$ {
root /usr/local/nagios/share;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
/usr/local/php/sbin/php-fpm start
他就会在本地还回接口启一个9000的listen。
然后nginx把带php文件的请求,丢给这个套接字转给php处理。
然后是支持cgi-bin
先用这个perl程序,在本地启一个8999的listen。
这个perl需要在CPAN上装三个包
use FCGI;
use Socket;
use FCGI::ProcManager;
然后nginx把cgi-bin的东东丢给perl处理
location ~ \.cgi$ {
root /usr/local/nagios/sbin;
rewrite ^/cgi-bin/(.*)\.cgi /$1.cgi break;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include nginx_fastcgi_params;
fastcgi_read_timeout 5m;
fastcgi_pass 127.0.0.1:8999;
}