Note: to use the Tcl script in nginx, the configuration process is recorded here and has been tested to be valid.
Install fcgiwrap
Fcgi-devel is required to install fcgiwrap. This package is included in epel and can be directly installed If epel is already installed.
Yum install fcgi-devel
Download and install fcgiwrap
Wget https://github.com/gnosek/fcgiwrap/archive/master.zip-O fcgiwrap.zip
Unzip fcgiwrap.zip
Fccd giwrap-master
Autoreconf-I # if an error is reported, install the automake package.
./Configure
Make
Make install
Install spawn-fcgi
Install the spawn-fcgi package to run fcgiwrap as a daemon.
Yum install spawn-fcgi
Edit the spawn-fcgi configuration file
Vi/etc/sysconfig/spawn-fcgi
Add the following content:
FCGI_SOCKET =/var/run/fcgiwrap. socket
FCGI_PROGRAM =/usr/local/sbin/fcgiwrap
FCGI_USER = nginx
FCGI_GROUP = nginx
FCGI_EXTRA_OPTIONS = "-M 0700"
OPTIONS = "-u $ FCGI_USER-g $ FCGI_GROUP-s $ FCGI_SOCKET-S $ FCGI_EXTRA_OPTIONS-F 1-P/var/run/spawn-fcgi.pid -- $ FCGI_PROGRAM"
NOTICE:-F 1 indicates to start a fcgiwrap process. If you have performance requirements, you can start several more
Add boot start:
Chkconfig spawn-fcgi on
Start the spawn-fcgi service:
Service spawn-fcgi start
Set nginx
Add the following configuration in nginx. conf:
Location/cgi-bin /{
Gzip off;
Root/var/www /;
Fastcgi_pass unix:/var/run/fcgiwrap. socket;
Include fastcgi_params;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fast
Cgi_script_name;
}
Create the/var/www/cgi-bin directory
Mkdir/var/www/cgi-bin
Grant nginx directory permissions
Chown-R nginx: nginx/var/www/cgi-bin
Create a test. cgi test file in the/var/www/cgi-bin directory.
#! /Usr/bin/tclsh
Puts "Content-type: text/html"
Puts ""
Puts "This is a tcl test script"
Modify the file permission so that it has the execution permission
Chmod 755 test. cgi
Open your browser and you will be able to see the script execution content.
Http: // localhost/cgi-bin/test. cgi
By now, the Tcl script can be executed in CGI mode, and the playability of the Tcl script is stronger. You can also execute bash, python, and other script languages in this way.