Installing mod_perl on Apache 24 Ubuntu 18.04

Posted by on Jan 20 2020, in kraxn

This is quite old school, but if you want to try mod_perl on Apache2.4 on Ubuntu, here’s how I did it:

First get the modules for Ubuntu server. If you were like me and trying to read the [installation process on the mod_perl website][1] , you probably were scratching your head. Luckily its trivial to install with just a couple of commands:

sudo apt-get update -y
sudo apt-get install -y libapache2-mod-perl2

Once that is done, just set up the virtual hosts, here is an example, just replace <> with your domain as well as any other directives. For the below, you can easily search and find the meanings of the directives:

<VirtualHost *:80>
         ServerAdmin webmaster@<>
         DocumentRoot /var/www/<>/public_html
        Servername <>
        Serveralias www.<>
       <Directory /var/www/<>
               AddHandler perl-script .pl .cgi
                PerlResponseHandler ModPerl::Registry
                Options +ExecCGI +FollowSymLinks +MultiViews
                 PerlOptions +ParseHeaders
                 AllowOverride All
               Order allow,deny
                Allow from all 
        ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined

As for why, I happen to like Perl. The webstuff is just for fun, but I’ve used to on my system to parse through large amount of text files, and it works great.

I know there is doom and gloom about the future of this language. I first heard of Perl’s demise in 2002, when I wanted to try to learn a scripting language outside of ASP. My Java programming mates thought it was horrible decision: Perl was considered old even then! However, not long after I started digging into Perl when I learned about PHP, and that became what I used for years. So I revisited Perl again, and wow, there is a very, very deep community. A google yields over 400,000 pages, though I suspect more. Even that archaic [mod_perl][2] was updated just a few months ago.

The Java guys? Not sure what happened to them. But its certainly fun to horse around with “Perl again before it disappears completely” 🙂