cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:web:nginx:note:cgi



Nginx Configuration Examples

How to use CGI in NGINX

Ubuntu

Install

# apt  install fcgiwrap

Configuration

/etc/nginx/sites-available/default

...

    #CGI
    location ~ \.cgi$ {
        root /var/www/html/;
        fastcgi_pass  unix:/var/run/fcgiwrap.socket;
        fastcgi_index  index.cgi;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

...


CentOS

Install

# yum install epel-release
# yum install spawn-fcgi fcgi-devel
# yum install fcgiwrap


Configuration of spawn-fcgi

/etc/init.d/fcgiwrap

# which fcgiwrap
/sbin/fcgiwrap

# vi /etc/sysconfig/spawn-fcgi
OPTIONS="-u nginx -g nginx -a 127.0.0.1 -p 9001 -P /var/run/spawn-fcgi.pid -- /sbin/fcgiwrap"

# systemctl status spawn-fcgi
# systemctl start spawn-fcgi
# systemctl status spawn-fcgi

# chkconfig --list
# /sbin/chkconfig spawn-fcgi on
# chkconfig --list


Configuration of Nginx

server {

(abbr)

    location ~ \.cgi$ {
        root /usr/share/nginx/html/;
        fastcgi_pass   127.0.0.1:9001;
        fastcgi_index  index.cgi;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

(abbr)

}



middleware/web/nginx/note/cgi.txt ยท Last modified: 2021/02/13 by admin

Page Tools