Getting Started with mod_perl in 30 Minutes
In the previous article, I passed along quite amazing Web performance reports from companies that have deployed mod_perl heavily. You might be surprised by this, but you can quite easily get similarly amazing results if you move your service to mod_perl as well. In fact, getting started with mod_perl shouldn't take you more than 30 minutes, the time it takes to compile and configure the server on a decent machine and get it running.Intimidated by the prospects of configuring mod_perl on your Apache server? Don't be. Getting started with mod_perl shouldn't take you more than 30 minutes, the time it takes to compile and configure the server on a decent machine and get it running. In this column, Stas Bekman explains how to get mod_perl up and running with a minimum of fuss.
In this article I'll show step-by-step installation and configuration scenarios, and chances are you will be able to run the basic statically compiled mod_perl setup without reading any other documents. Of course, you will want and need to read the documentation later, but I think you will agree with me that it's ultimately cool to be able to get your feet wet without knowing much about the new technology up-front.
The mod_perl installation was tested on many mainstream Unix platforms, so unless you have some very non-standard system you shouldn't have any problems when building the basic mod_perl server.
If you are a Windows user, the easiest way is to use the binary package available from http://perl.apache.org/distributions.html. From the same location you can download the Linux RPM version and CVS snapshots. However, I recommend to always build the mod_perl from source, and as you will see in a moment, it's an easy thing to do.
So let's start with the installation process. If you are an experienced Unix user, you need no explanation for the following commands. Just copy and paste them and you will get the server installed.
I'll use a
% sign as the shell program's prompt:
% cd /usr/src
% lwp-download http://www.apache.org/dist/apache_1.3.12.tar.gz % lwp-download http://perl.apache.org/dist/mod_perl-1.24.tar.gz % tar -zvxf apache_1.3.12.tar.gz % tar -zvxf mod_perl-1.24.tar.gz % cd mod_perl-1.24 % perl Makefile.PL APACHE_SRC=../apache_1.3.12/src DO_HTTPD=1 USE_APACI=1 PERL_MARK_WHERE=1 EVERYTHING=1 % make && make test && make install % cd ../apache_1.3.12 % make install
What's left is to add a few configuration lines to
an Apache configuration file, start the server, and enjoy mod_perl.
If you have stumbled upon a problem at any of the above steps, don't despair--the next section will explain in detail each and every step.
Just as advertised in the previous section--the building time stays the same: 10 minutes, but if one of the steps didn't work for you or you didn't have the courage to try it, I will explain each step in fine details here. If everything was just fine you can skip this section and move on to the next one.
First you have to become a root user in order to install the files in a protected area. If you don't have root access, you can install all the files under your home directory as well. We will talk about the nuances of this approach in a future article. I'll also assume that you have perl and cc or an equivalent C compiler installed.
I assume that all builds are being done in the
directory. So we go into this directory:
% cd /usr/src