Tutorials  /  Linux Basics

Install Perl on Arch Linux with Apache or Nginx Support

Ccentron Redaktion · July 2025 ·4 min read ·Linux Basics, Tutorial

Requirements

  • A server with the latest Arch Linux version installed.
  • An operational web server (either Apache or Nginx).
  • Sudo privileges:
    • Commands that must be executed as root are marked with #.
    • It is recommended to run these commands by prepending sudo as a standard user.
  • A text editor you are comfortable with, such as vi, vim, nano, emacs, or any similar tool.
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Installing Perl 5.28 on Your Web Server

Perl is included in the Arch base group, so it is typically installed alongside the system.

Setting Up Perl with Apache

  1. Install the mod_perl package from the Arch User Repository (AUR). Refer to Arch Linux’s guide on building packages from the AUR.
  2. To activate the Apache Perl module, edit the file /etc/httpd/conf/httpd.conf and append this line to the list of LoadModule directives:
Code
LoadModule perl_module modules/mod_perl.so
  1. For every <Directory> block where you wish to allow Perl script execution, insert the following configuration:
Code
<Directory "/srv/http/cgi-bin">
    AllowOverride None
    Require all granted
    AddHandler perl-script .pl
    AddHandler perl-script .cgi
    PerlResponseHandler ModPerl::Registry
    Options +ExecCGI
    PerlOptions +ParseHeaders
</Directory>

If the section already includes Options None, make sure to remove or comment it out.

  1. When using multiple virtual hosts, you must also modify /etc/httpd/conf/httpd.conf by commenting out the ScriptAlias directive to prevent all /cgi-bin/ requests from being routed to /srv/http/cgi-bin/ for every host:
Code
<IfModule alias_module>
...
    #ScriptAlias /cgi-bin/ "/srv/http/cgi-bin/"
</IfModule>
  1. Restart Apache to apply changes:
Console
# systemctl restart httpd
  1. Create the required directory:
Console
# mkdir /srv/http/cgi-bin

Setting Up Perl with Nginx

  1. Install FCGI Wrap:
Console
# pacman -S fcgiwrap
  1. Enable FCGI Wrap and make it start automatically at boot:
Console
# systemctl enable --now fcgiwrap.socket
  1. To allow Nginx to use FCGI Wrap, modify /etc/nginx/nginx.conf and add this block to each server section that should handle Perl scripts. If you use virtual hosts, edit each one accordingly:
Code
location ~ /cgi-bin/.*\.(cgi|pl)$ {
    root         /usr/share/nginx/html/;
    fastcgi_pass unix:/run/fcgiwrap.sock;
    include      fastcgi.conf;
}
  1. Create the necessary directory:
Console
# mkdir /usr/share/nginx/html/cgi-bin/

Verifying Perl Functionality

  1. In the corresponding CGI directory, generate a file named test.cgi containing the following script:
Code
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "perl works\n";
  1. Ensure the script is executable:
Console
# chmod +x test.cgi
  1. Navigate to http://YOUR-SERVER-WEB-ADDRESS-OR-IP/test.cgi in your web browser. If everything is configured properly, you will see the message: perl works.
  2. Don’t forget to remove the test.cgi file after the test.

Conclusion

By following this guide, you’ve successfully enabled Perl 5.28 support on an Arch Linux web server using either Apache or Nginx. Whether you chose mod_perl or FCGI Wrap, your setup is now capable of executing Perl scripts, and ready for more complex CGI applications. Always remember to remove test files and ensure proper permissions and configurations for production use.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren