Well, it won't be exactly the same architecture obviuosly. But it can be similar. You'll have to install and configure mod_perl. The feature you'll want to use is ModPerl::Registry which allows you to run your Perl program as if it were a CGI program. You'll need to make a few changes in the script itself:
- Have some other logic for passing the command line options. If they should be dynamic, use a query string or something. If they should be static, have them come from config variables in your Apache config
- You'll have to generate the proper response headers for "CGI" output. Now you're presumably doing it in the PHP script, so you have to do that in Perl instead.
- Likewise with whatever cosmetic changes you're doing.
| [reply] |
Some ideas (speculation without knowing what your Perl is doing)-
- Rewrite the Perl code in PHP and use it directly; they can translate pretty directly sometimes.
- Turn the Perl script into a daemon listening on a socket or a URI and have the PHP make the requests there. This is essentially the same solution as mod_perl but *might* be easier depending on the situation and your Perl chops. Search CPAN or here for "daemon" for modules and recommendations.
- mod_perl. Errto's registry suggestion is probably the easiest way to do this.
- Turn your script into fastcgi (FCGI). It is generally easier and more likely to be available/supported than mod_perl. They are roughly equivalent in terms of performance. mod_perl is much deeper but its apache hooks are rarely needed in plain web scripting.
Whatever you pick, you're in for a bit of work/learning. I'd personally go with the fastcgi solution. Good luck.
| [reply] |
First you should determine whether mod_perl will actually help. mod_perl is helpful when you've got a LOT of requests coming in for a resource, and each of those requests result in a process being spawned, and this process start/stop cycle can take up a lot of resources. If this is the case, mod_perl can help (you're having resource issues because you have too many requests coming in).
However, if your perl script is taking up resources because it's doing something resource-intensive, likely mod_perl won't help. For example, if it's only accessed occasionally and if it's taking an hour to run and pegging the cpu/disk/memory/whatever because it's processing a huge file, mod_perl won't help. | [reply] |