Nginx Perl Error

While working on Nginx compilation from source, we got the error ‘Can’t load ‘/usr/local/lib64/perl5/auto/nginx/nginx.so”. In this post we are sharing the solution to fix this issue.

Problem Statement

The problem occur when we were trying to install the Nginx 1.6.0 version on CentOS 7.
It was nginx perl module ,we were enabling while compiling.

In given below code snippet, you can find the error.

[root@localhost nginx-1.6.0]# /usr/sbin/nginx
Can't load '/usr/local/lib64/perl5/auto/nginx/nginx.so' for module nginx: /usr/local/lib64/perl5/auto/nginx/nginx.so: undefined symbol: ngx_http_perl_handle_request at /usr/share/perl5/XSLoader.pm line 68.
at /usr/local/lib64/perl5/nginx.pm line 56.
Compilation failed in require.
BEGIN failed--compilation aborted.
nginx: [alert] perl_parse() failed: 255
[root@localhost nginx-1.6.0]#

As per Nginx when you run the configure with help switch you will find the Perl Module option for enabling. Find this in given below code snippet.

./configure --help
--with-http_perl_module            enable ngx_http_perl_module

Solution

To solve this problem use the below given additional option with configure script (i.e --with-ld-opt="-Wl,-E")

./configure --with-http_perl_module --with-ld-opt="-Wl,-E"

And then use below given command for further Nginx installation

make && make install

We hope this solution also works for you and now you are able to proceed for Nginx source installation procedure.

Read Some More Articles

7 Comments

  1. I have nginx compiled with the same options but still I am getting the “undefined symbol” error on my centos7 server

    any pointers
    Can’t load ‘/usr/lib64/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Nginx/Nginx.so’ for module Nginx: /usr/lib64/perl5/lib/perl5/x86_64-linux-thread-multi/auto/Nginx/Nginx.so: undefined symbol: ngx_http_perl_handle_request at /usr/share/perl5/XSLoader.pm line 68.
    at /usr/lib64/perl5/lib/perl5/x86_64-linux-thread-multi/Nginx.pm line 110.
    Compilation failed in require at /usr/local/share/perl5/Nginx/Redis.pm line 15.
    BEGIN failed–compilation aborted at /usr/local/share/perl5/Nginx/Redis.pm line 15.
    Compilation failed in require at Trigger.pm line 6.
    BEGIN failed–compilation aborted at Trigger.pm line 6.
    You have new mail in /var/spool/mail/root

    1. Hi Ramprasad,

      Which Nginx version are you installing.
      The error is showing on “/usr/local/share/perl5/Nginx/Redis.pm” , do you need redis module ?

      I appreciate if you could provide the all commands which you are using for installing Nginx.

      Regards
      Sharad

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.