Perlshop 4 - Web Server Configuration

Overview

Perlshop 4 web server software is based upon a set of files that are placed on your web server. These files are grouped into two general categories:

  1. The Perlshop program and its support files -
    This category includes the main perlshop.cgi program file, the ps.cfg file, and the various Perlshop program library files.
  2. Supporting html, JavaScript, and CSS files -
    This category includes the Perlshop JavaScript library files, such as ps_utilities.js, and the various HTML, CSS, and image files that are included with the Perlshop software. The Perlshop CGI software is not involved in using these files - they are accessed directly from the web server by the web client (i.e. a web browser or web search spider).

On a typical web server, these two categories of files are stored under two different directory structures. The following example is common for a Unix web server with multiple users. In this example, the user account directory is named waverider. Files from the first category are stored under the /home/waverider/cgi-bin directory, and the files from the second category are stored under the /home/waverider/public_html directory:


Directory Configuration - Traditional CGI

This section of the document describes a traditional directory configuration that can be used by any version of Perlshop. All of the Perlshop CGI files are stored under the /home/waverider/cgi-bin/perlshop directory. The Perlshop catalog pages are stored under the /home/waverider/cgi-bin/perlshop/catalog directory and are not available for direct access by web clients.

This architechture makes for simple installation and configuration, but has disadvantages where web search engines are concerned (see the document Dancing with Search Engines for more details on this topic).

See the document Preparing Your Web Server for simple instructions on creating this directory structure on your own web server prior to Perlshop installation.


 


Directory Configuration - Public Catalog Pages

Overview

This directory architecture is identical to that shown in the previous section, save that it moves the catalog web page directory out of the cgi-bin area and into the public_html area. This makes the catalog web pages available to web clients like search spiders.

The problem with this directory architecture is that it is still not possible to provide your customers with direct URLs to your catalog pages. This is because the catalog pages contain Perlshop data tags embedded within the HTML, and these tags must be processed by Perlshop before they can be displayed in a web browser.

There are several techniques that can be applied to your catalog pages that can resolve this issue.
 

Technique 1 - Dancing with Search Engines

The document Dancing with Search Engines describes a JavaScript mechanism that can be added to each catalog web page. This JavaScript code will be executed by the browser as the page is being loaded, providing automatic URL redirection for each catalog page.

 
Example: If a web client requests a standard catalog page URL like this:
http://www.yourstore.com/catalog/page1.html
 
their web browser will be automatically redirected to a Perlshop like this:
http://www.yourstore.com/cgi-bin/perlshop/perlshop.cgi?ACTION=enter&thispage=page1.html&ORDER_ID=!ORDERID!

This technique works well for all web browsers and for many search engines. Increasingly, however, search engines like Google do not like working with URL redirection. A more sophisticated approach is needed for modern web sites.

 

Technique 2 - Using the Apache Web Server Action Command

This technique works only with the Apache web server. It has been used successfully with Apache versions 1.2 and 2.0. No changes to your catalog web pages are required in order to use this technique.

This technique requires that you add a custom Apache .htaccess file to the catalog html directory on your web server. In the case of the example directory structure shown above, the full name of this file would be /home/waverider/public_html/catalog/.htaccess. This file must contain the following command:

Action text/html /cgi-bin/perlshop/perlshop.cgi

This command instructs Apache to process all files of MIME type text/html in that directory through the program /cgi-bin/perlshop/perlshop.cgi.

Please note:

  1. This technique will work only with Perlshop version 4.5 or later.
  2. Your web server must be configured to allow custom .htaccess files of this type. (Web server configurations vary from one ISP to another. Check with the support staff at your ISP before attempting to use this technique.)
  3. Your ps.cfg file must contain the following settings:
    1. $use_cookies = 'yes'
    2. $cookie_domain = '/perlshop'
    3. $offer_restart_on_return = 'no'

 
Example 1: If a web client requests a standard catalog page URL like this:
http://www.yourstore.com/catalog/page1.html
 
Apache will respond as if the following URL had been requested:
http://www.yourstore.com/cgi-bin/perlshop/perlshop.cgi?ACTION=enter&thispage=page1.html&ORDER_ID=!ORDERID!

 
Example 2: If a web client requests a PSDBI catalog page URL like this:
http://www.yourstore.com/catalog/psdbi/page1.html
 
Apache will respond as if the following URL had been requested:
http://www.yourstore.com/cgi-bin/perlshop/perlshop.cgi?ACTION=enter&thispage=psdbi/page1.html&ORDER_ID=!ORDERID!

 

Technique 3 - Using the Apache Web Server AddHandler Command

This technique works only with the Apache web server. It has been used successfully with Apache versions 1.2 and 2.0.

This technique requires that you add a custom Apache .htaccess file to the catalog html directory on your web server. In the case of the example directory structure shown above, the full name of this file would be /home/waverider/public_html/catalog/.htaccess. This file must contain the following commands:

Options +ExecCGI
AddHandler cgi-script html

The first command enables CGI execution inside your catalog web page directory, which is something Apache would not normally do. The second command instructs Apache to process all files with an html suffix in that directory as though they were CGI scripts. Together, these commands tell Apache to treat your catalog web page files just like any other web server CGI program.

Please note:

  1. This technique will work only with Perlshop version 4.5 or later.
  2. Your web server must be configured to allow custom .htaccess files of this type. (Web server configurations vary from one ISP to another. Check with the support staff at your ISP before attempting to use this technique.)
  3. Your ps.cfg file must contain the following settings:
    1. $use_cookies = 'yes'
    2. $cookie_domain = '/perlshop'
    3. $offer_restart_on_return = 'no'
  4. You must modify each of your catalog web pages to support this technique.

In order to use this technique, the first line of each catalog html page must contain a Unix instruction that tells the server how to execute that file, and the second line of each catalog web page must be blank. For example:

#!/usr/local/bin/perl /home/waverider/cgi-bin/perlshop/perlshop.cgi

<html>

<head>
<title>Test Page - Apache</title>
</head>

<body>
<h1>Test Page - Apache</h1>
Your order ID is !ORDERID!.<br>
</body>

</html>

The first line of the file contains two parts. The first part is your web server's path to its Perl installation. This part will be the same as in the first line of your perlshop.cgi file. The second part of the command is the full file name of your perlshop.cgi file.