1

I spent a few days searching for answers on serverfault and elsewhere, and tried them all to no avail. I'm trying to serve dynamic content using perl cgi scripts (Apache 2.4.29 on Ubuntu 18.04.2). The perl scripts are served to the browser as plaintext instead of being executed and their results served.

My VirtualHost file looks like this:

    ServerAdmin webmaster@localhost
    DocumentRoot /data/www/html/tesserae-obvil

    <Directory /data/www/html/tesserae-obvil/>
    Options Indexes FollowSymLinks
    AllowOverride all
    Require all granted
    </Directory>

    ScriptAlias /cgi-bin/ /data/www/html/tesserae-obvil/cgi-bin/
    <Directory "/data/www/html/tesserae-obvil/cgi-bin/">
    Options +ExecCGI +Indexes +MultiViews
    Options FollowSymLinks
    SetHandler cgi-script
    Require all granted
    </Directory>


    ErrorLog /data/www/log/error.log
    CustomLog /data/www/log/access.log combined
                                                                                                  </VirtualHost>

I have enabled the cgi module with sudo a2enmod cgi, installed perl for Apache with sudo apt-get install libapache2-mod-perl2and restarted Apache. Right now my best working theory is that Apache2 is not loading Perl properly. I found some instructions on setting up CGI, but even though they are supposed to be for the current version, they mention adding a LoadModule line to httpd.conf, which I gather is depreciated.

I have run out of ideas. Can anybody help?

  • 2
    Your perl files are executable? You can run perl outside of apache? – Lenniey Apr 16 '19 at 14:55
  • anything in the log files? – natxo asenjo Apr 16 '19 at 20:08
  • Thanks for the responses. Yes, the perl files execute from the command line. No, unfortunately there's nothing relevant in the log files. – James Gawley Apr 17 '19 at 12:55
  • 1
    Any luck with `AddHandler cgi-script .cgi .pl`? – Lenniey Apr 17 '19 at 13:52
  • `LoadModule cgid_module modules/mod_cgid.so` is present in your config somewhere? – Lenniey Apr 17 '19 at 14:36
  • I added the `LoadModule cgid_module modules/mod_cgid.so` line to the site's .conf file, after line. I assume that everything in his file is read by apache on startup. Still getting .pl files as text, I'm afraid. – James Gawley Apr 17 '19 at 14:42
  • Could you post an example perl script you try to load through apache? – Lenniey Apr 18 '19 at 07:52
  • Well, the perl scripts are pretty long because it's a clone of an open source webtool called [Tesserae](https://github.com/tesserae/tesserae). So the script in question is [for comparing two texts](https://github.com/tesserae/tesserae/blob/master/cgi-bin/read_table.pl). But for the sake of your question – James Gawley Apr 19 '19 at 14:15
  • I made a dummy script that consists of just this: `#!/usr/bin/env perl print "What's up.";`. The script's source code loaded as text without executing. Could is be some kind of firewall problem? The server is on a university network, and originally the scripts were blocked entirely from loading. But the admin made an exception in the firewall for my cgi-bin folder. That's when they started loading, but only as text. – James Gawley Apr 19 '19 at 14:34

0 Answers0