|
Install Apache using the Synaptic Package Manager as part of the LAMP (Linux Apache MySql PHP) systenm:
Apache will now start each time you boot your system. In a terminal window, cd to /usr/lib/cgi-bin Many of the following commands require root privs. You can preceed each command with sudo, or, type: sudo su which will (after you enter your password) put you in a shell where you are root and the sudo is no longer necessary. You return to non-priv state by typing exit. create a file named test-cgi.cgi with the following contents (cut and paste): #!/bin/sh # disable filename globbing set -f echo Content-type: text/plain echo 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 Reset permissions of test-cgi: chmod a+x test-cgi.cgi In your Ubuntu browser, type the URL: 127.0.0.1/cgi-bin/test-cgi.cgi This should run the test-cgi script which will report some details about your operating environment. The results will look something like:
cd to /var/www and modify the default web page index.html to something like: chmod a+r index.html In your browser, type the URL: 127.0.0.1 You should see your default page. To run an executable program, try the following Mumps script (see http://cns2.uni.edu/~okane/source/MUMPS-MDH/. Download and install from the highest numbered mumpscompiler...) In /usr/lib/cgi-bin create mtest.mps with the following contents: mumpsc mtest.mps Its protections should be correct. In the browser, type: 127.0.0.1/cgi-bin/mtest.cgi You should see "test test test" on a gray screen. Try a bash script to access PostgreSQL through apache cgi-bin. Write btest.cgi in /usr/lib/cgi-bin as follows:
#!/bin/bash
# disable filename globbing
set -f
echo Content-type: text/plain
echo
echo Database test
echo `whoami`
psql -f f1 -d medical
Note: if you cut and paste these, be sure to remove any
leading blanks or tabs from the lines.
|