Cantech Knowledge Base

Your Go-To Hosting Resource

How to Install Perl 5.28 on an Arch Linux Webserver?

Perl also known as “Practical Extraction and Report Language” is a cross-platform, open-source, general-purpose programming language that is widely used in both commercial and private sectors. Its main goal is to provide extra power for text processing and system management. Perl by itself is writing syntax similarly to the C language and has some features of the other languages like BASIC, AWK, and Shell scripting. Perl is a language that is flexible not only in its syntax but also the type of problem it can solve. Thus, it is used as a programming language in several different areas like web development, network programming, and GUI development. The language is good as far as manipulating texts or binary files is concerned, it is also a top pick for the development of CGI programs. Perl’s mobility is its most significant advantage, as it facilitates a collaborative community that can be accessed from different locations around the world.

This blog will help you configure your Arch Linux web server to execute Perl scripts using either Apache or Nginx.

Pre-requisites

Before you proceed, make sure you have the following:

  • Arch Linux Server: An up-to-date Arch Linux system.
  • Web Server: Apache or Nginx installed and running.
  • Sudo Privileges: Ability to execute commands with superuser permissions.
  • Text Editor: Familiarity with editors like vi, vim, nano, or emacs for configuration file modifications.

Instructions to Install Perl 5.28 On Web Server

On Arch Linux, Perl is pre-installed as part of the base system.

How to Install Perl For Apache?

1. Install mod_perl

The integration of the Perl interpreter directly into the Apache server through mod_perl enables Perl scripts to run with enhanced performance. The Arch User Repository (AUR) offers mod_perl which you can install through an AUR helper such as yay:

yay -S mod_perl

If you don’t have an AUR helper installed, you can manually build and install mod_perl by following the Arch Wiki guidelines on AUR installation.

2. Allow the Perl Module in Apache

Edit the Apache configuration file (/etc/httpd/conf/httpd.conf) and add the following line to load the Perl module:

LoadModule perl_module modules/mod_perl.so

3. Configure the cgi-bin Directory

Ensure that the directory intended for CGI scripts is properly configured. Add or modify the <Directory> block in your Apache configuration:

<Directory "/srv/http/cgi-bin">
    AllowOverride None
    Require all granted
    Options +ExecCGI
    AddHandler cgi-script .cgi .pl
</Directory>

4. Restart Apache

After making all these changes, we have to restart Apache to enable them:

sudo systemctl restart httpd

How to Install Perl For Nginx

1. Install fcgiwrap

Install fcgiwrap using pacman:

sudo pacman -S fcgiwrap

2. Enable and Start fcgiwrap

Start the fcgiwrap service and enable it to start on boot:

sudo systemctl enable --now fcgiwrap.socket

3. Configure Nginx to Handle Perl Scripts

Edit your Nginx configuration (e.g., /etc/nginx/nginx.conf or a specific server block configuration) to include:

location ~ \.pl$ {
    root            /usr/share/nginx/html;
    fastcgi_pass    unix:/run/fcgiwrap.sock;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}

This configuration directs Nginx to process .pl (Perl) scripts using fcgiwrap.

4. Restart Nginx

Apply the changes by restarting Nginx:

sudo systemctl restart nginx

Test Perl

To confirm that Perl is correctly installed and configured:

1. Create a Test Perl Script

In your web server’s cgi-bin directory (e.g., /srv/http/cgi-bin for Apache or /usr/share/nginx/html for Nginx), create a file named test.pl with the following content:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "Perl is working!";

2. Make the Script Executable

Set the required permissions:

chmod +x /srv/http/cgi-bin/test.pl

3. Access the Script via a Web Browser

Navigate to http://your_server_ip/cgi-bin/test.pl. If configured correctly, you should see the message “Perl is working!“.

FAQ’s

1. How to Install ActiveState Perl?

  • ActiveState offers a precompiled Perl distribution known as ActivePerl. To install it on Windows:
  • Download the installer from ActiveState’s official website.
  • Run the installer and follow the on-screen instructions.
  • Ensure you run the installer with administrative privileges to allow all users to access Perl and to ensure all features function correctly.

2. Is Perl Easy to Use?

Perl is very flexible and expressive and is often summarized by the motto “There’s more than one way to do it.” This allows programmers to choose among many different approaches toward solving a given problem; therefore catering to varying programming styles. But this very flexibility can make the code, if not properly controlled, complex and hard to read. It seems that Perl syntax is simple enough to learn, and that learning some of its more subtle behaviors, or the enormous number of modules in the library, needs time and practice.

3. Where Is Perl Used Today?

Perl remains a versatile tool for various applications today, especially in areas where text processing and system administration are of importance. Some specific applications are:

  • Web Development: Perl has been utilized for developing web applications and dynamic websites.
  • System Administration: Automating tasks like file administration, user management, and network moni-toring.
  • Text Processing: Efficiently handling tasks like log file analysis, data extraction, and report generation.
  • Bioinformatics: The BioPerl collection of modules is used for the analysis of biological data.
  • Finance: Another use has been writing scripts and applications for data parsing and reporting.

4. Is Perl Backend or Frontend?

Perl is predominantly identified as a backend language. It’s well suited for server-side development, where it performs essential functions such as the linking of servers to databases, server scripting, and the processing of backend logic. While Perl can be used for some of the frontend stuff, like generating HTML or handling forms, it is seldom used for frontend tasks that would typically be handled using JavaScript. Frameworks such as Catalyst allow you to build powerful backend applications using Perl.

March 20, 2025