Perl CGI  «Prev  Next»

Lesson 8Installing the guestbook
ObjectiveGet the guestbook example running on your server.

Installing the Guestbook in Perl

This lesson continues to use the guestbook example discussed in previous lessons. You will also need the htmlp files available for download from the course Resources page. In this lesson, we will go through the steps necesary to run the guestbook on your server.
Getting the Guestbook to run on your Server
In order to get the guestbook to run on your server, you will need to edit the program and fill in a few important variables with the appropriate data for your server. You will find these variables at the top of the program, under the heading:
# data space 

Now each of the variables in turn:
$datadir = "/path/to/the/guestbook/datafiles"; 

This is the directory for the guestbook data files. The directory you use must have appropriate permissions set for the Web server to create and rename files. The program needs to do this because there is no other portable way to write a new entry to the head of a file.
Under Unix, you can use chmod 0777 directory to set the permissions.
$dataname = "luna.dat"

This is the name of the data file. Name it something meaningful to you. (I used "luna" because it is the name of my Web server.)

$datafile = "$datadir/$dataname";
$tempfile = "$datadir/$dataname.$$"; 

These two are derivative of the first two. You can safely leave them alone.
$lockfile = "/tmp/$dataname.lock"; 

The lock file will have to be placed in a directory where you can create and remove a temporary file. This is /tmp on most Unix systems. It may be something else on other operating systems.


Installing Guest Book - Exercise

Click the Exercise link below to load the Guestbook CGI onto your own server and experiment with the htmlp files.
Installing Guest Book - Exercise

SEMrush Software