Server Setup
By: Paul Vining
The base...
This column will contain approaches and tips to create dynamic web pages. I will provide snippets of code and tell about my
approaches to various problems that I have encountered. If you choose to use different tools on your server, my explanations
should give you enough information to go on. Since this is the first column, I will start off by explaining how to get to
where I started off. Everything that I will discuss will work on both WinXX and linux platforms.
The best solution I have found.
Before choosing this software, I looked at all the tools out there, and picked the ones that had the brightest future, the
most development ongoing, and were the most flexible. I found that the combination of Apache/mod_perl/Embperl/MySQL can fit
the bill in almost any regard. Everything works cross-platform and is extremely flexible. Apache as a webserver is
battle-proven and extremely reliable. Mod_perl enables the caching of perl and drastically increases the speed of any perl
script. Embperl is a module for Apache that allows the embedding of perl scripts in the actual HTML code. Mysql is the
database server we choose for our development, again because of its speed and cross platform qualities. There are more
powerful database servers out there, but MySQL was built for speed from the very beginning and continued development make it a
good choice for web development.
Before beginning, all of the steps are important and should be done in the order noted. Please don't try to use the
ActiveState version of Perl until they support mod_perl.
WIndows setup...
First let me dispel a myth that has been circulating about Win32 and Apache/mod_perl.
Mod_perl runs fine under Apache for Win32. How fine? Try Windows 98 with 8MB of RAM on a 486 DX2/66 fine (oh did I mention the
MySQL server helping with dynamic content). Now it didn't take any names as far as speed goes under this configuration, but it
ran.
If you are going to run Apache/mod_perl on Win32 you don't have to have a compiler, Jeffrey Baker offers a pre compiled
version of 5.005_02 Apache 1.3.3 and mod_perl 1.16 on CPAN in the WWW directory, but I preferred to compile my own and I am
sure a lot of people out there would like to also. Here goes.
Download the latest version of:
Apache
Perl
mod_perl
HTML::Embperl
HTML::Parser
MD5
MIME::Base64
MySQL
Compile Perl first. Read the Win32 instructions carefully. Then build the HTML::Parser, HTML::Embperl, MD5, MIME::Base64 modules.
On the HTML::Embperl module you will be asked whether you want to build with mod_perl support, answer no this time we will
rebuild in a couple of steps.
Now compile Apache. The documentation on their site walks you through the install.
Once Apache is build you can build mod_perl. First build the perl portion of mod_perl with the standard
perl Makefile.PL EVERYTHING=1, nmake. nmake install. SKIP the nmake test for now. Mod_perl is build under VisualC++ 5.0 and
all the instructions that come with it are based on this. Read the instructions very carefully, I have had difficulty every
time. My VisualC++ was not install correctly the first time and some Win32 libraries weren't linked correctly. Despite what I
thought was a problem with mod_perl, it was me. Double check that all the libs are correct and all the paths are correct for
any files you have included, I don't know if it my lack of knowledge or a VC++ "feature",
but when I include files on another partition or hard drive the path is always wrong.
Once you compile the mod_perl dll move it into the X:\Apache\modules directory.
Now we rebuild the HTML::Embperl module with mod_perl support. You'll need to be able to tell it where the src is.
Note: The HTML::Embperl module test suite doesn't always run successfully this is normal (if all the tests fail soething is
wrong).
Then run the mod_perl nmake test.
Now all we have to do is configure the httpd.conf, access.conf, and srm.conf files.
You can put all the information into one file, the httpd.conf, which I recommend if you are familiar with Apache.
Add the following to the http.conf file.
***********************************
PerlModule HTML::Embperl
SetEnv EMBPERL_DEBUG 0
SetHandler perl-script
PerlHandler HTML::Embperl
Options ExecCGI
***********************************
**Note this parses everything with .htm? extensions. Change to .epl or whatever extension you wish to parse.
Fill in the appropriate information for the Serverroot and etc. in the file also.
Next uncompress and install MySQL according to your platform.
Linux setup...
Download the latest version of:
Apache
Perl
mod_perl
HTML::Embperl
HTML::Parser
MD5
MIME::Base64
MySQL
If your system doesn't have perl, download and compile it on your platform. Then build the HTML::Parser, HTML::Embperl, MD5, MIME::Base64 modules.
On the HTML::Embperl module you will be asked whether you want to build with mod_perl support, answer no this time we will rebuild in a couple of steps.
For Apache, mod_perl, and Embperl, the installation will go much smoother if you place all the tar.gz files in the same
directory (so there are parallel directory structures).
Uncompress apache, mod_perl, and embperl with tar -zxvf on each of them. cd into the apache directory, edit the Configuration
file per your system, and make apache per the readme. cd.. and then cd into the mod_perl directory and make according to the
readme , and make sure you "perl Makefile.PL EVERYTHING=1". Next, cd.. cd into the Embperl directory and make according to the
readme. Next, cd.. and cd back into the mod_perl directory and remake it according to the readme, this time do a make test and
it should pass every test (most importantly the embperl test).
Add the following to the http.conf file.
***********************************
PerlModule HTML::Embperl
SetEnv EMBPERL_DEBUG 0
SetHandler perl-script
PerlHandler HTML::Embperl
Options ExecCGI
***********************************
**Note this parses everything with .htm? extensions. Change to .epl or whatever extension you wish to parse.
Fill in the appropriate information for the Serverroot and etc. in the file also.
Next uncompress and install MySQL according to your platform.
That essentially concludes the initial setup of the server. In the following columns I will demonstrate how to create dynamic
pages based on databases and a variety of perl modules. For a good start the Embperl package has fairly good documentation and
quite a few examples.