I'm trying to run a perlscript as a cgi-Script. However including the cgi-library of perl doesn't work:
# perl -e 'use CGI::Carp qw(fatalsToBrowser);'
Can't locate CGI/Carp.pm in @INC (you may need to install the CGI::Carp module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
#On an old server the same command does not produce an error message and cgi scripts run properly.
This seems to be a perl-problem, not an Apache problem.
On my servcer Carp.pm is already installed in one of the paths given in @INC:
# find /usr -iname 'Carp.pm' -ls
555093613 20 -rw-r--r-- 1 root root 20074 Aug 24 21:47 /usr/lib/x86_64-linux-gnu/perl-base/Carp.pm
382731053 20 -rw-r--r-- 1 root root 20074 Mär 13 2016 /usr/share/perl/5.22.1/Carp.pm
# How do I get the cgi-Library included. I'm using Ubuntu 16.04 LTS.
2 Answers
Partially answering this for my own archiving. This seems to be a recent error that stems from a broken dependency. I got a similar error message when check the error log.
tail -100 /var/log/apache2/error.log
... AH01215: Can't locate CGI.pm in @INC (you may need to install the CGI module)
...After some detective work, I traced this to the following dependency (sorry I lost my source).
sudo apt-get install libcgi-session-perl 1 In my case, this problem was caused by incorrect file and directory permissions within the various system perl5/ directories. The files need to be readable by the user under which the webserver is running. The program files (.pl) need to be executable. The directories need to be readable and searchable.