问题
I am trying to install mod_perl2 with below configuration:
OS: CentOS release 5.5 (Final)
Uname -a result: x86_64 x86_64 x86_64 GNU/Linux
Perl version: v5.8.8 built for x86_64-linux-thread-multi
apache version: Apache/2.2.3
I have downloaded mod_perl2 from Cpan site
when I try to run the "perl Makefile.PL MP_APXS=/usr/local/httpd/bin/apxs" it gives below output:
Subroutine set_version redefined at ./Makefile.PL line 137.
[ info] generating script t/TEST
[ info] generating script ./t/cgi-bin/cookies.pl
[ info] generating script ./t/cgi-bin/next_available_port.pl
Checking for Cwd...ok
Checking for File::Spec...ok
[ info] generating script t/TEST
Generating a Unix-style Makefile
Writing Makefile for mod_perl2
[warning] mod_perl dso library will be built as mod_perl.so
[warning] You'll need to add the following to httpd.conf:
[warning]
[warning] LoadModule perl_module modules/mod_perl.so
[warning]
[warning] depending on your build, mod_perl might not live in
[warning] the modules/ directory.
[warning] Check the results of
[warning]
[warning] $ /usr/local/httpd/bin/apxs -q LIBEXECDIR
[warning] [warning] and adjust the LoadModule directive accordingly.
After "make" command runs below error occurs:
modperl_env.c: In function ‘modperl_env_magic_local_all’:
modperl_env.c:544: error: ‘MGf_LOCAL’ undeclared (first use in this function)
modperl_env.c:544: error: (Each undeclared identifier is reported only once
modperl_env.c:544: error: for each function it appears in.)
modperl_env.c: At top level:
modperl_env.c:642: warning: excess elements in struct initializer
modperl_env.c:642: warning: (near initialization for ‘MP_vtbl_env’)
modperl_env.c: In function ‘modperl_env_init’:
modperl_env.c:661: warning: passing argument 2 of ‘Perl_mg_find’ discards
qualifiers from pointer target type
modperl_env.c:673: warning: implicit declaration of function ‘mg_free_type’
modperl_env.c:678: error: ‘MGf_LOCAL’ undeclared (first use in this function)
modperl_env.c: In function ‘modperl_env_unload’:
modperl_env.c:690: warning: passing argument 2 of ‘Perl_mg_find’ discards
qualifiers from pointer target type
make1: * [modperl_env.lo] Error 1
make1: Leaving directory `/opt/mod_perl-2.0.10/src/modules/perl'
make: * [modperl_lib] Error 2
any help is appriciated, if i have asked somthing wrong please guide further (no down votes please :) )
回答1:
This constant as been introduced in perl 5.9.3, and mod_perl use it from 2.0.10.
http://search.cpan.org/~vpit/Variable-Magic-0.62/lib/Variable/Magic.pm#MGf_LOCAL https://perl5.git.perl.org/perl.git/commit/a5063e7cd8fef802efd25ffe9df2c3748f4254f6 https://github.com/apache/mod_perl/commit/82827132efd3c2e25cc413c85af61bb63375da6e https://perldoc.perl.org/perlguts.html
to overcome this you must modify mod_perl to use this constant conditionaly of the perl version:
diff -ruw mod_perl-2.0.11/src/modules/perl/modperl_env.c mod_perl-2.0.11.patched/src/modules/perl/modperl_env.c
--- mod_perl-2.0.11/src/modules/perl/modperl_env.c 2017-12-06 11:08:55.000000000 -0500
+++ mod_perl-2.0.11.patched/src/modules/perl/modperl_env.c 2018-03-27 15:02:14.174790000 -0400
@@ -541,7 +541,9 @@
nmg = sv_magicext(nsv, mg->mg_obj, mg->mg_type, &MP_vtbl_env, (char*)NULL, 0);
nmg->mg_ptr = mg->mg_ptr;
nmg->mg_flags |= MGf_COPY;
+#if MP_PERL_VERSION_AT_LEAST(5, 9, 3)
nmg->mg_flags |= MGf_LOCAL;
+#endif
return 1;
}
@@ -679,7 +681,9 @@
/* Add our version instead */
mg = sv_magicext((SV*)ENVHV, (SV*)NULL, PERL_MAGIC_env, &MP_vtbl_env, (char*)NULL, 0);
mg->mg_flags |= MGf_COPY;
+#if MP_PERL_VERSION_AT_LEAST(5, 9, 3)
mg->mg_flags |= MGf_LOCAL;
+#endif
}
void modperl_env_unload(pTHX)
回答2:
A modified/enhanced version of Mathieu Carbonneaux's patch above was committed to the mod_perl SVN repository on October 8th, 2019:
http://svn.apache.org/viewvc?view=revision&revision=1868115
With this patch, mod_perl 2.0.11 will compile and install using Perl <= 5.8.8.
(Sorry, I don't have the reputation to comment, only answer.)
回答3:
Why are you trying to build your own version of mod_perl? Centos has a pre-built version of mod_perl which will work with the pre-built version of Perl that is already installed.
$ sudo yum install mod_perl
(Of course, this won't help if you're not using the system Perl)
回答4:
dont know how but mod_perl-2.0.6 has got installed successfully. had no success with the mod_perl-2.0.10 :(
来源:https://stackoverflow.com/questions/40745426/error-when-installing-mod-perl2