Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Let apache execute the CGI program

Shulou Source: shulou.com Published: 2022-06-01 01:06:36 10月04日 Update

Set up Apache to execute CGI program

Visit http://192.168.10.10/cgi-bin/test

You are accessing the cgi program in a different directory.

When this is set, any file in the cgi-bin directory runs as a CGI program.

Set the files in the cgi-bin directory to be executed with CGI.

You can execute the CGI program in a file in a directory other than cgi-bin. Add the ExecCGI option after options.

Set the file with the corresponding suffix to be executed as a CGI program

When this is set up, .cgi, .sh (shell), .pl (perl) files in other directories will be executed as CGI programs, not as text files.

Http://10.10.103.14:8088/CGI/test.sh

Example:

Shell script:

Test.sh

[c-sharp] view plaincopy

#! / bin/sh

# disable filename globbing

Set-f

Echo "Content-type: text/plain; charset=iso-8859-1"

Echo # there must be a blank line output here, as specified by all CGI programs

Echo CGI/1.0 test script report:

Echo

Echo argc is $#. Argv is "$*".

Echo

Echo SERVER_SOFTWARE = $SERVER_SOFTWARE

Echo SERVER_NAME = $SERVER_NAME

Echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE

Echo SERVER_PROTOCOL = $SERVER_PROTOCOL

Echo SERVER_PORT = $SERVER_PORT

Echo REQUEST_METHOD = $REQUEST_METHOD

Echo HTTP_ACCEPT = "$HTTP_ACCEPT"

Echo PATH_INFO = "$PATH_INFO"

Echo PATH_TRANSLATED = "$PATH_TRANSLATED"

Echo SCRIPT_NAME = "$SCRIPT_NAME"

Echo QUERY_STRING = "$QUERY_STRING"

Echo REMOTE_HOST = $REMOTE_HOST

Echo REMOTE_ADDR = $REMOTE_ADDR

Echo REMOTE_USER = $REMOTE_USER

Echo AUTH_TYPE = $AUTH_TYPE

Echo CONTENT_TYPE = $CONTENT_TYPE

Echo CONTENT_LENGTH = $CONTENT_LENGTH

Tags: Programs files directories suffixes instances text blank lines scripts add process output run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info Docker Huawei vpn