For memo...
INSTALL
# sudo apt-get install apache2
TEST if Apache2 installed successfully ?
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
MODIFY for CGI
# sudo vi /etc/apache2/apache2.conf
:
AddHandler cgi-script .cgi
:
# sudo vi /etc/apache2/sites-enabled/000-default
:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory /var/www/cgi-bin/>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
:
RESTART Apache2 via apache2ctl
# sudo apache2ctl configtest
# sudo apache2ctl restart
PREPARE a CGI for test
# cd /var/www/cgi-bin
# vi a.cgi
#!/bin/sh
echo "Content-type: text/html\n\n"
cat <<EOF
<html><body>
Hello World !<br>
QUERY_STRING: <font color=0000ff>$QUERY_STRING</font><br>
Bye !
</body></html>
EOF
# sudo chmod 755 a.cgi
TEST if the CGI works ?
http://localhost/cgi-bin/a.cgi?a=b&c=d
Hello World !
QUERY_STRING: a=b&c=d
Bye !
ERROR ??? Very important if you got something wrong ...
# tail /var/log/apache2/error.log