spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / perl / mysqlperl / chap3 / 2 current pageTo page 2To page 3To page 4To page 5
[next]
Developer News
Get Ready for Microsoft's 'Oslo' Modeling Tool
Latest Linux Hits Networking Flaws
Metasploit 3.2 Offers More 'Evil Deeds'

Improving Performance with mod_perl

mod_perl Configuration

Apache uses a standard protocol, the Common Gateway Interface (CGI), to communicate with externally executed scripts such as those we put in the cgi-bin directory in the preceding chapter. When a CGI script begins executing, it can assume that Apache has set up certain environment variables. For example, REMOTE_ADDR and REQUEST_URI indicate the client's host IP number and the request path. When Apache uses mod_perl to execute a script directly, it doesn't set up the CGI environment. In principle, there is no need, because a script that has direct access to Apache's internals obviously can extract that information itself if it wants. But the practical implication of this is that Perl CGI scripts won't function properly under mod_perl unless they are rewritten to use the Apache API or unless something else sets up the CGI environment for them.

Obviously, the latter alternative is preferable. If you already have a bunch of CGI scripts, you don't want to rewrite them all specifically for mod_perl. Fortunately, there is an easy solution to this problem. mod_perl includes an Apache::Registry module that sets up the CGI environment for you. If we use it to run our CGI scripts, mod_perl becomes transparent to them so that (for the most part) they don't need to know or care whether they're being run by a standalone Perl process or by mod_perl. This enables you to move your scripts between the standalone and mod_perl execution environments easily.1

Oh, you noticed that "for the most part" in the preceding paragraph, did you? That disclaimer was necessary because scripts containing certain constructs need modification for mod_perl. We'll get to this in the section titled "Writing mod_perl Scripts."

The rest of this section describes how to configure Apache to use mod_perl and Apache::Registry for running Perl scripts. The steps are as follows:

  1. Create a directory for mod_perl scripts.
  2. Verify that mod_perl is installed.
  3. Configure httpd.conf to tell Apache how to execute mod_perl scripts.
  4. Test your configuration.
  5. Set up a mod_perl startup file (optional, but useful).

Before following these instructions, verify that you have recent enough versions of Perl and CGI.pm. You should have Perl 5.005 or higher. You should also have CGI.pm 2.36 or higher, because earlier versions don't work with mod_perl. If your versions aren't recent enough, you'll need to upgrade. See Appendix A, "Obtaining Software," for instructions.

1. Clearly, I'm making an argument for being able to write scripts that run whether or not you have mod_perl installed, so that readers who can't install mod_perl or who elect not to will be able to run most of the scripts in this book without modification. There is a counterargument, which is that if you know you're going to use mod_perl, you can get even better performance by dispensing with Apache::Registry and interacting more directly with Apache.

home / programming / perl / mysqlperl / chap3 / 2 current pageTo page 2To page 3To page 4To page 5
[next]



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Intel Article: Using Power & Display Context in the Intel Mobile Platform SDK
Internet.com eBook: Real Life Rails
IBM SCA Center Article: Simplifying Composite Applications with Service Component Architecture
Intel PDF: Quad-Core Impacts More Than the Data Center
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Intel PDF: Analysis of Early Testing of Intel vPro in Large IT Departments
Internet.com eBook: Best Practices for Developing a Web Site
Intel PDF: IT Agility through Automated, Policy-based Virtual Infrastructure
IBM CIO Whitepaper: The New Information Agenda. Do You Have One?
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
IBM Whitepaper: How are other CIOs driving growth?
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Actuate Download: Free Visual Report Development Tool
Red Gate Download: SQL Backup Pro
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
IBM SCA Download: Start Building SCA Applications Today
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES
webref The latest from WebReference.com Browse >
Anatomy of an Ajax Application · Popular JavaScript Framework Libraries: An Overview · Controllers: Programming Application Logic - Part 2
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags


Created: July 2, 2001
Revised: July 2, 2001


URL: http://webreference.com/programming/perl/mysqlperl/chap3/2/