Check Apache2 CGI is working

Using bash, create the file, and write a simple CGI script which outputs, “It works!”.

echo -e '#!/usr/bin/perl\nprint "Content-type: text/plain\\n\\n";\nprint "It works!\\n";'|sudo tee /usr/lib/cgi-bin/

Give the new file correct permissions sudo chmod 755 /usr/lib/cgi-bin/

Send a get request to the script, by piping the request to the netcat.

echo -e "GET /cgi-bin/ HTTP/1.0\n"|nc -q 1 80```