Prerequisites
- A Rcs server running up to date Arch Linux (see this article.)
- A running webserver, either Apache or Nginx
- Sudo access:
- Commands required to be ran as root are prefixed by #. The recommended way to run commands as root is to, as a regular user, prefix each of them withsudo
- Have a text editor installed, and be familiar with it, such as vi, vim, nano, emacs or a similar editor
Install Perl 5.28 On Your Webserver
Perl is part of the Arch base group, so it was installed along with the rest of Arch.
For Apache
Install the AUR (Arch User Repository) package mod_perl. See Building Packages on Arch Linux (Including the AUR).
Enable the Apache Perl module by editing /etc/httpd/conf/httpd.conf, and at the end of the list of LoadModule commands, add the following:
LoadModule perl_module modules/mod_perl.soMake each Directory section you want to be able to run Perl scripts contain these options the following options.
<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>Note if you are editing an existing Directory section, and it already contains Options None, comment that line out or delete it.
If you are running multiple host directories, you also need to edit /etc/httpd/conf/httpd.conf and comment out the ScriptAlias command as shown, or all "/cgi-bin/" web requests will be served out of /srv/http/cgi-bin/ regardless of which host it is:
<IfModule alias_module>
...
    #ScriptAlias /cgi-bin/ "/srv/http/cgi-bin/"
</IfModule>Restart Apache:
# systemctl restart httpdCreate the appropriate directory:
# mkdir /srv/http/cgi-binFor Nginx
Install FCGI Wrap:
# pacman -S fcgiwrapStart FCGI Wrap, and make it start after every boot:
# systemctl enable --now fcgiwrap.socketAllow Nginx to use FCGI Wrap by editing /etc/nginx/nginx.conf, and to every server block you want to use Perl, add the following: Alternatively, if you are using virtual hosts, edit each host's configuration file:
location ~ /cgi-bin/.*\.(cgi|pl)$ {
    root         /usr/share/nginx/html/;
    fastcgi_pass unix:/run/fcgiwrap.sock;
    include      fastcgi.conf;
}Create the appropriate directory:
# mkdir /usr/share/nginx/html/cgi-bin/Test Perl
Within the appropriate directory, create test.cgi with contents:
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "perl works\n";Make it executable, (required for perl scripts):
# chmod +x test.cgiIn a web browser, visit http://YOUR-SERVER-WEB-ADDRESS-OR-IP/test.cgi, and you will see perl works.
Be sure to delete the test.cgi test file you just created.
