Saturday, February 13, 2010

Solaris 10: Using CGI on Apache2 for beginners

Abstract: There are many helpful books and web-pages to assist beginning CGI programmers. Unfortunately most assume that one is uploading their files to a professionally administered server. This blog is aimed at those who have full access to a stock Solaris 10/Apache2 webserver.

Step 1: Enable Apache2 according to this post.

2: Login as super-user.

3: Change the cgi-bin folder permissions.

# chmod 775 /var/

4: Save a valid cgi file to the ../cgi-bin directory. My test file is "first.cgi" which is borrowed from the excellent tutorial "CGI Programming 101" by Jaqueline Hamilton.
#!/usr/bin/perl -wT 
print "Content-type: text/html\n\n";

print "Hello, world!\n";

5: Set the file permissions.

# chmod 755 ..cgi-bin/first.cgi

6: Access your website to test the file.

You should see "Hello World" on a plain background (or whatever your test file specified should happen).


Solaris 10 comes with Apache and Apache2 installed (but inactive). Ensure that you don't confuse them (i.e. saving files in the wrong directories).

Apache2 does not require .cgi at the end of CGI files but does require the full file name when running it in a browser.

No comments:

Post a Comment