Perl
  Home arrow Perl arrow Page 3 - Introduction to mod_perl (part 2): mod_perl Quickstart
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PERL

Introduction to mod_perl (part 2): mod_perl Quickstart
By: Stas Bekman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 2
    2002-05-07


    Table of Contents:
  • Introduction to mod_perl (part 2): mod_perl Quickstart
  • Installing mod_perl Detailed
  • Configuring and Starting mod_perl Server
  • The "mod_perl rules" Apache::Registry Script
  • The "mod_perl rules" Apache Perl Module
  • Is This All I Need to Know About mod_perl?
  • Acknowledgements
  • References

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Introduction to mod_perl (part 2): mod_perl Quickstart - Configuring and Starting mod_perl Server
    ( Page 3 of 8 )

    First thing first we want to make sure our Apache was built correctly and that we can serve plain HTML files with it. Why do that? To minimize the number of possible trouble makers, if we find out that mod_perl doesn't work. After you know that Apache can serve HTML files, you don't have to worry about it anymore. And if something goes wrong with mod_perl, you have eliminated the possibility that the httpd binary or basic configurations are broken, you know you are allowed to bind to the port you have configured your server to listen to, and that the browser you're testing with is just fine. Again, you should follow these guidelines when installing mod_perl for the first time.

    Configure Apache as you always do. Set Port, User, Group, ErrorLog and other directives in the httpd.conf file (remember I've asked you to remember the location of this file at the end of the previous section?). Use the defaults as suggested, customize only when you have to. Values that you need to customize are ServerName, Port, User, Group, ServerAdmin, DocumentRoot and a few others. You will find helpful hints preceding each directive. Follow them if in doubt.

    When you have edited the configuration file, it's time to start the server. One of the ways to start and stop the server is to use the apachectl utility. You start the server with:

    % /usr/local/apache/bin/apachectl start
    And stop it with:

    % /usr/local/apache/bin/apachectl stop
    Note that you have to be root when starting the server if the server is going to listen on port 80 or another privileged port (1024).

    After you start the server, check in the error_log file (/usr/local/apache/logs/error_log is the file's default location) that the server has indeed started. Don't rely on the status apachectl reports. You should see something like the following:

    [Thu Jun 22 17:14:07 2000] [notice] Apache/1.3.20 (Unix) mod_perl/1.26 configured -- resuming normal operations
    Now point your browser to http://localhost/ or http://your.server.name/ as configured with the ServerName directive. If you have set a Port directive with a value different from 80, apply this port number at the end of the server name. If you have used port 8080, test the server with http://localhost:8080/ or http://your.server.name:8080/ . You should see the infamous "It worked" page, which is an index.html file that make install in the Apache source tree installs for you. If you don't see this page, something went wrong and you should check the contents of the error_log file. You will find the path of the error log file by looking it up in the ErrorLog directive in httpd.conf.

    If everything works as expected, shut the server down, open httpd.conf in your favorite editor, and scroll to the end of the file where we will add the mod_perl configuration directives (of course you can place them anywhere in the file).

    Assuming that you put all scripts that should be executed by the mod_perl enabled server in the /home/httpd/perl/ directory, add the following configuration directives:
    Alias /perl/ /home/httpd/perl/
      
    PerlModule Apache::Registry
    <Location /perl>
      SetHandler perl-script
      PerlHandler Apache::Registry
      Options ExecCGI
      PerlSendHeader On
      allow from all
    </Location>

    Save the modified file.

    This configuration causes every URI starting with /perl to be handled by the Apache mod_perl module. It will use the handler from the Perl module Apache::Registry. {mospagebreak title=Preparing the Scripts Directory} Now create a /home/httpd/perl/ directory if it doesn't yet exist. In order for you and Apache to be able to read, write and execute files we have to set correct permissions. You could get away by simply doing:

    % chmod 0777 /home/httpd/perl
    This is very very insecure and you should not follow this approach on the production machine. This is good enough when you just want to try things out and want to have as few obstacles as possible. Once you understand how things work, you should tighten the permissions of files served by Apache. In future articles we will talk about setting proper file permissions.



     
     
    >>> More Perl Articles          >>> More By Stas Bekman
     

       

    PERL ARTICLES

    - More Perl Bits
    - Perl, Bit by Bit
    - Basic Charting with Perl
    - Using Getopt::Long: More Command Line Option...
    - Command Line Options in Perl: Using Getopt::...
    - Web Access with LWP
    - More Templating Tools for Perl
    - Site Layout with Perl Templating Tools
    - Build a Perl RSS Aggregator with Templating ...
    - Looping, Security, and Templating Tools
    - Perl: Bon Voyage Lists and Hashes
    - Templating Tools
    - Perl: Number Crunching
    - Perl Debuggers in Detail
    - Debugging Perl





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek