There is still a tug war between mod_perl and FCGI in the speed race. I clearly don’t know which one is faster, anyways, it shouldn’t prevent us from using one or another, both does their job perfectly. Lets install and setup the mod_perl for Apache2 in Ubuntu very easily and efficiently.
First check if the mod_perl is available in ubuntu repository
sudo apt-cache search mod-perl
It should give result like:
libapache2-mod-perl2 - Integration of perl with the Apache2 web server libapache2-mod-perl2-dev - Integration of perl with the Apache2 web server - development files libapache2-mod-perl2-doc - Integration of perl with the Apache2 web server - documentation libfile-chmod-perl - chmod() override with symbolic and ls-style modes libhtml-wikiconverter-usemod-perl - HTML to wiki markup converter - UseMod dialect liblinux-usermod-perl - Linux::usermod - modify user and group accounts libwiki-toolkit-formatter-usemod-perl - UseModWiki-style formatting for CGI::Wiki wzdftpd-mod-perl - modular, small and efficient ftp server - Perl module
Now lets install the libapache2-mod-perl2 and the development version
sudo apt-get install libapache2-mod-perl2 libapache2-mod-perl2-dev
Now, we have to ask Apache to use mod_perl for our files containing Perl extensions. Go to /etc/apache2/sites-available/default and edit the file to put the Perl config. You can put it anywhere between the <VirtualHost></VirtualHost>, preferably just before the ending.
sudo gedit /etc/apache2/sites-available/default ### Now put the following codes before the end of your virtual host. <Files ~ "\.(pl|cgi)$"> SetHandler perl-script PerlResponseHandler ModPerl::Registry Options +ExecCGI PerlSendHeader On </Files>
All Perl files in your working directory will now use mod_perl to execute via Apache2. Last but not the least, restart the Apache server
sudo service apache2 restart