Deprecated Perl and Apache2 Code

I have to maintain a prehistoric website with tons of Perl code. After switching to a new server, everything turned out fuzzy:

When several requests of the same client are working on the page (generating images using GD), these scripts rewrite each other's variables, which leads to strange results.

As a quick workaround, I set MaxRequestsPerChild = 1 in Apache, which fixes this, but now everything slows down to a workaround ...

Is there a way to separate requests? Any mod_perl or Apache options that could help me?

Apache:

Server version: Apache/2.2.15 (Unix) Server built: Apr 3 2014 23:56:16 Server Module Magic Number: 20051115:25 Server loaded: APR 1.3.9, APR-Util 1.3.9 Compiled using: APR 1.3.9, APR-Util 1.3.9 Architecture: 64-bit Server MPM: Prefork threaded: no forked: yes (variable process count) 

perl -v

 This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi 

Any solution for this would be very helpful :)


EDIT: I could not find the correct way to fix things with mod_perl, but the following workaround works:

  • Disable mod_perl
  • Enable mod_cgi
  • AddHandler cgi- script.pl
  • Disable suEXEC

The latter was necessary because it gave me a "premature end to script headers" when suEXEC was enabled.

+6
source share
1 answer

No, you cannot do anything to "separate requests." All scripts running in the same Perl interpreter process will share the same environment, while mod_perl will share the constant environment. You can try ModPerl::Registry up ModPerl::Registry to run them (if you havenโ€™t already), which should wrap them in your own routine and fix some namespace problems, but if the scripts are not written with persistence (*) you donโ€™t care will have to modify them, at least to some extent.

http://perl.apache.org/docs/2.0/user/intro/start_fast.html#Registry_Scripts

You may also encounter problems when scripts use certain modules, such as SOAP :: Lite, which have a global state that is used for all modules that use it, although this is a much rarer problem.

So, no, unfortunately, you canโ€™t do anything to make the scripts work fine without changing them. Some may be fine, others will not. Perhaps you should configure a regular Apache CGI server besides a separate mod_perl server, and gradually reconfigure them. You wonโ€™t get performance on a regular CGI server, but you wonโ€™t have any problems either.

(*) In particular, and this is from the memory of many, many moons ago, they should avoid setting global variables, always declare variables using my , use the CGI module (or mod_perl API) for query interaction and such things.

0
source

Source: https://habr.com/ru/post/970246/


All Articles