has always been in the terminal execution shell and other scripts, whether the Web interface can also do so, of course, is also possible
This article takes CentOS 6 as an example to install the configuration
- Installing spawn-fcgi
wget Https://github.com/lighttpd/spawn-fcgi/archive/spawn-fcgi-1.6.4.zip
Unzip Spawn-fcgi-1.6.4.zip && RM spawn-fcgi-1.6.4.zip
MV spawn-fcgi-spawn-fcgi-1.6.4/spawn-fcgi
CD spawn-fcgi/
./autogen.sh
./configure
Make && make install
- Installing Fcgiwrap
Yum-y Install fcgi fcgi-devel nginx
wget Https://github.com/gnosek/fcgiwrap/archive/1.1.0.zip
Unzip 1.1.0.zip
RM 1.1.0.zip
MV Fcgiwrap-1.1.0/fcgiwrap
CD fcgiwrap/
Autoreconf-i
./configure
Make && make install
- Add Fcgiwrap startup script
Script enable user to be consistent with your Nginx boot user, note the path in the script and start the user
Vim/etc/init.d/fcgiwrap
#! /bin/bash### BEGIN INIT info# provides:fcgiwrap# Required-Start: $remote _fs# Required-Stop: $remote _fs# should-start:# should-stop:# Default-start:2 3 4 5# Default-stop:0 1 6# Short-description:fastcgi wrapper# description:simple Server forrunning CGI applications over fastcgi### END INIT INFOPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binspawn_fcgi="/usr/local/bin/spawn-fcgi"DAEMON="/usr/local/sbin/fcgiwrap"NAME="Fcgiwrap"Pidfile="/var/run/$NAME. PID"Fcgi_socket="/tmp/$NAME. Socket"Fcgi_user="Nginx"Fcgi_group="Nginx"Fork_num=5ScriptName=/etc/init.d/$NAME Case " $" inchstart)Echo-N"starting $NAME ..."PID=`pidof$NAME 'if[!-Z"$PID"]; Then Echo "$NAME already running"Exit1 fi$SPAWN _fcgi-U $FCGI _user-g $FCGI _group-s $FCGI _socket-p $PIDFILE-F $FORK _num-F $DAEMONif["$?"!=0]; Then Echo "failed"Exit1 Else Echo " Done" fi ;; Stop)Echo-N"stoping $NAME ..."PID=`pidof$NAME 'if[!-Z"$PID"]; Then Kill`pidof$NAME 'if["$?"!=0]; Then Echo "failed. Re-quit"Exit1 Else RM-F $pidEcho " Done" fi Else Echo "$NAME is not running."Exit1 fi ;; Status) PID=`pidof$NAME 'if[!-Z"$PID"]; Then Echo "$NAME (PID $PID) is running ..." Else Echo "$NAME is stopped"Exit0 fi ;; Restart) $SCRIPTNAME StopSleep 1$SCRIPTNAME start;; *) Echo "Usage: $SCRIPTNAME {start|stop|restart|status}"Exit1 ;;EsacFcgiwrap
chmod +x/etc/init.d/fcgiwrap
- Start
Chkconfig--add Fcgiwrap
Chkconfig--level 2345 Fcgiwrap on
./etc/init.d/fcgiwrap Restart
- Nginx Configuration
Test environment Edit/etc/nginx/conf.d/default.conf, add
Location ~ ^/cgi-bin/cgi/.*\. (cgi| SH { #这里的后缀匹配根据需要修改, you can use the unified CGI suffix gzip off; Fastcgi_pass Unix:/tmp/fcgiwrap.socket; Fastcgi_index index.cgi; Include Fastcgi_params; Fastcgi_param script_name $document _root$fastcgi_script_name; }
Restart Nginx:
Nginx-s Reload
Mkdir-p/usr/share/nginx/html/cgi-bin Place Home HTML
Mkdir-p/usr/share/nginx/html/cgi-bin/cgi Placement Script
- Script Test
vim/usr/share/nginx/html/cgi-bin/cgi/disk.cgi
#!/bin/BashEcho "Content-type:text/html;charset=utf-8"Echo ""#前3行必须是这个格式, the HTML code uses the Echo,linux command as well as the scripting syntaxEcho '<div style= "padding-left:10px;" >'Echo ''Echo ''DD=`Date`Echo "Statistics Time: $dd"Echo ''Echo '<pre style= "border-left:4px solid RGB (A, A, 245);p adding:5px" >'DF-HTEcho '</pre>'
disk.cgi
Visit: http://your-ip/cgi-bin/cgi/disk.cgi
Nginx Support Web Interface Execution Bash script