In this tutorial I will show you how to install mod_Perl.
Perl/CGI is a very powerful programming language but when used for web applications it can really tax your server’s resources, specifically the CPU. With CGIProxy, a web based anonymizer similar to Proxify.com; I had noticed my server’s load (A 3.4ghz Pentium 4 with HT and 2GB of RAM) consistently hitting 40 during peak hours.
Fortunately this particular script was designed to work with mod_perl. Mod_perl is an apache module that loads a separate perl interpreter inside apache at the minute cost of memory and with a drastic reduction of CPU usage.
After configuring mod_perl with apache for this particular script, the server load at peak hovers is healthy at 2, even with twice the visitors!
Configuring mod_perl to work with apache was difficult for me at first, so hopefully this article assist anyone interested in putting this wonderful module to use. This tutorial is geared for a cPanel server running Apache 1.x and mod_perl 1.x however the httpd.conf instructions should work with any Apache 1.x server with mod_perl installed.
Ensure you are logged in as root in shell and follow these steps:
Compile mod_perl with apache in cPanel:
1. type: /scripts/easyapache
2. check for “Perl Module” and make sure it’s enabled
3. Save and Exit
To verify that Apache was configured with mod_perl type:
It should list: mod_perl.c
Now that Apache has mod_perl loaded as a module, we’ll need to edit our httpd.conf (Apache Config. File) but first it’s a good idea to make a back up:
1. Go into the Apache conf directory: cd /usr/local/apache/conf/
2. Backup: cp httpd.conf httpd.conf.bak
3. Edit: pico httpd.conf
Go to where it your modules are being loaded, it should be under the “Dynamic Shared Object (DSO) Support” section. Add the following line under the last loaded module:
Now we’ll need to the following information to make any CGI script inside the cgi-bin to be processed with mod_perl & apache instead of Perl.
allow from all
The above lines were added inside the VirtualHost entry of my ProxyMy.com account.
Go ahead and save the file, exit, and restart Apache.
To verify that the changes check your running processed by typing in the command: top cd1
If the CGI script is still running from Perl then the process command will begin with something similar to: /usr/local/bin/perl. However if you see a copy of Apache loading when the CGI process is executed (/usr/local/apache/bin/httpd -DSSL) then congrats, you’ve configured mod_perl successfully!
Was this post helpful?
Let us know, if you liked the post. Only in this way, we can improve us.