cgi
Nginx0.8.34 支持 CGI
1 安装FCGI
root@njava:~# wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz root@njava:~# tar -zxf FCGI-0.67.tar.gz root@njava:~#cd FCGI-0.67 root@njava:~/FCGI-0.67# perl Makefile.PL root@njava:~/FCGI-0.67# make && make install root@njava:~/FCGI-0.67# cd ..
2 安装FCGI-ProcManager
root@njava:~# wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz root@njava:~#tar -zxf FCGI-ProcManager-0.18.tar.gz root@njava:~#cd FCGI-ProcManager-0.18 root@njava:~/FCGI-ProcManager-0.18#perl Makefile.PL root@njava:~/FCGI-ProcManager-0.18#make && make install root@njava:~/FCGI-ProcManager-0.18#cd ..
3 安装IO-ALL
root@njava:~#wget http://search.cpan.org/CPAN/authors/id/I/IN/INGY/IO-All-0.39.tar.gz root@njava:~# tar zxf IO-All-0.39.tar.gz root@njava:~#cd IO-All-0.39 root@njava:~/IO-All-0.39# perl Makefile.PL root@njava:~/IO-All-0.39# make && make install
4 安装nginx-fcgi脚本
root@njava:~#wget http://www.nginx.eu/nginx-fcgi/nginx-fcgi.txt root@njava:~#mv nginx-fcgi.txt /usr/sbin/nginx-fcgi root@njava:~# chmod +x /usr/sbin/nginx-fcgi
不以root权限执行脚本,注释nginx-fcgi
#if ( $> == "0" ) { # print "\n\tERROR\tRunning as a root!\n"; # print "\tSuggested not to do so !!!\n\n"; # exit 1; #}
5启动nginx-fcgi
nginx-fcgi -l /var/log/nginx/nginx-fcgi.log -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock chown www-data:www.data /var/run/nginx-fcgi.sock
注意nginx-fcgi.sock的权限让nginx的执行账户有权读写
6 复制fastcgi_params一份用来设置nginx_fcgi_params
root@njava:~#cp /etc/nginx/fastcgi_params /etc/nginx/nginx_fcgi_params root@njava:~#vi /nginx/nginx_fcgi_params #fastcgi_param REDIRECT_STATUS 200;
7 代理cgi设置
server { listen 80; server_name njava.com; location ~ ^/cgi-bin/.*\.cgi$ { root /home/bear/njava/test; fastcgi_index index.cgi; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include nginx_fcgi_params; fastcgi_read_timeout 5m; fastcgi_pass unix:/var/run/nginx-fcgi.sock; } }
8 完工