WHM Perl Module Locations @INC
I am in the process of migrating from my current cPanel VPS to a new cPanel VPS.
My application is using Perl, and thus needs access to the Perl Modules. I have installed all the Perl Modules that are on my current VPS to the new VPS.
Many of the Perl Modules that are used in our application are in a directory in my cPanel account, in the cgi-bin directory:
home/abccompany/public_html/cgi-bin
When I test my application on the new vps I get an error message saying the Perl Modules in my cPanel account can't be located.
This makes sense because I haven't set the @INC environment to look in my cgi-bin directory.
This was done on my current server many years ago and the programmer that set this up is no longer around. I am a novice at much of this, so I need help.
On my current server, when I type command:
perl -e 'printf "%d %s\n", $i++, $_ for @INC'
I get:
root [/]# perl -e 'printf "%d %s\n", $i++, $_ for @INC'
0 /usr/local/lib64/perl5
1 /usr/local/share/perl5
2 /usr/lib64/perl5/vendor_perl
3 /usr/share/perl5/vendor_perl
4 /usr/lib64/perl5
5 /usr/share/perl5
6 .
root [/]# _
On the new server, when I type the same command, I get:
root [/]# perl -e 'printf "%d %s\n", $i++, $_ for @INC'
0 /usr/local/lib64/perl5
1 /usr/local/share/perl5
2 /usr/lib64/perl5/vendor_perl
3 /usr/share/perl5/vendor_perl
4 /usr/lib64/perl5
5 /usr/share/perl5
root [/]# _
As you can see, on the current server, line 6 is . (I'm not sure about the ( . ) but I think it is important because someone suggested it represents the 'current working directory' in my cPanel account. They suggested I run:
export PERL5LIB=.
When I tried this the server hung and nothing happened. When I ran the command above again, it is the same as before.
What command do I run, and where do I run it, to set the cgi-bin, or the 'current working directory' to be included in @INC?
Do I need to issue this command from a certain directory? Can this be done using cPanel's Terminal?
All help is greatly appreciated.
Thank you!
-
When I tried this the server hung and nothing happened.
Did the entire server hang (i.e. no SSH access existing or new, no web pages etc) or did the existing SSH connection just hang? Was it straight after you typed that command? If so, I suspect that as you ran it as root it "screwed up" cPanel itself (which uses Perl). Since you are trying to get Perl to work for a website, I would not be issuing these commands as root - but rather as the username of the hosting account for that website. Either login via SSH using their username or, from the root SSH, switch to their username usingsu -
. Depending on the server specific setups, paths for a particular user (and hence any scripts which run as the user) may be different from those provided to the root user (and, in fact, update the cage before anything else.- Is the list of Perl modules for the server identical on both servers (WHM->Software->Install a Perl Module) - if not, try Is the list of Perl modules for the user identical on both servers - see "Software->Perl Modules. See also "Does the Perl script work if you run
perl scriptname.pl
in the folder where the script is located as the user? (see " You say the error message reads "Perl Modules in my cPanel account can't be located". I don't believe that is the exact error message - could you let us know what the error message actually is (feel free to change any mention of your username, server name, IP address) as it'll give more guidance as to the problem. Does the listing for @INC stay the same when you are logged in as the user on both servers (you might find usingenv -i perl -V
quicker to show the list of paths) ? Is the Perl version different on the server (Perl 5.26+ might not have the current working directory [.] set if it is running with user's .bashrc file (~/.basrc) for it to persist. I would recommend adding "use lib '/ home/abccompany/public_html/cgi-bin';
" to the script instead of changing server variables. Hope it helps!0 - Is the list of Perl modules for the server identical on both servers (WHM->Software->Install a Perl Module) - if not, try Is the list of Perl modules for the user identical on both servers - see "Software->Perl Modules. See also "Does the Perl script work if you run
-
Thank you rbairwell for your input. When I said the server hung, the terminal window just didn't give any response after I entered export PERL5LIB=. I expected something to return, but nothing did. I was able to close the window and continue. When I entered perl -e 'printf "%d %s\n", $i++, $_ for @INC' again, the response is always the same as the first time. Everything on the server is working as expected. I don't know if there is a specific way to test Perl to make sure it is working correctly or not. Here is the error message that came back the first time I tried to run a Perl script: Can't locate ABC/dothisnow.pm in @INC (you may need to install the ABC::dothisnow module) (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /home/abccompany/public_html/cgi-bin/client_login.pl line 12. BEGIN failed--compilation aborted at /home/abccompany/public_html/cgi-bin/client_login.pl line 12. The script, client_login.pl was run from the cgi-bin directory, and the module dothisnow.pm is in the subdirectory ABC of the cgi-bin directory. home/abccompany/public_html/cgi-bin/ABC/ The old server is using Perl v5.16.3, and the new is using v5.26.3. I came across this which may be important here: 0
Please sign in to leave a comment.
Comments
2 comments