leestretton.com

You are in: > Home > Developers Guides

Perl - Configuring and Starting the mod_perl Server

Perl Camel

The first thing to do is ensure that Apache was built correctly and that it can serve plain HTML files. This helps to minimize the number of possible problem areas: once you have confirmed that Apache can serve plain HTML files, you know that any problems with mod_perl are with mod_perl itself.

Apache should be configured just the same as when it did not have mod_perl. Set the Port, User, Group, ErrorLog and other directives in the httpd.conf file. Use the defaults as suggested, customizing only when necessary. Values that will probably need to be customized are ServerName, Port, User, Group, ServerAdmin, DocumentRoot and a few others. There are helpful hints preceding each directive in the configuration files themselves, with further information in Apache's documentation. Follow the advice in the files and documentation if in doubt.

When the configuration file has been edited, it is time to start the server. One of the ways to start and stop the server is to use the apachectl utility. This can be used to start the server with:

# /usr/local/apache/bin/apachectl start

And stop it with:

# /usr/local/apache/bin/apachectl stop

Note that if the server is going to listen on port 80 or another privileged port (Any port with a number less than 1024 can be accessed only by the programs running as root.), the user executing apachectl must be root.

After the server has started, check in the error_log file (/usr/local/apache/logs/error_log by default) to see if the server has indeed started. Do not rely on the status apachectl reports. The error_log should contain something like the following:

[Thu Jun 22 17:14:07 2000] [notice] Apache/1.3.12 (Unix) 
  mod_perl/1.24 configured -- resuming normal operations

Now point the browser to http://localhost/ or http://example.name/ as configured with the ServerName directive. If the Port directive has been set with a value different from 80, add this port number at the end of the server name. For example, if the port is 8080, test the server with http://localhost:8080/ or http://example.com:8080/. The infamous "It worked" page should appear in the browser, which is an index.html file that make install in the Apache source tree installs automatically. If this page does not appear, something went wrong and the contents of the error_log file should be checked. The path of the error log file is specified in the ErrorLog directive section in httpd.conf.

If everything works as expected, shut the server down, open httpd.conf with a plain text editor, and scroll to the end of the file. The mod_perl configuration directives are added to the end of httpd.conf by convention. It is possible to place mod_perl's configuration directives anywhere in httpd.conf, but adding them at the end seems to work best in practice.

Assuming that all the scripts that should be executed by the mod_perl enabled server are located in the /home/stas/modperl directory, add the following configuration directives:

  Alias /perl/ /home/stas/modperl/
  
  PerlModule Apache::Registry
  
      SetHandler perl-script
      PerlHandler Apache::Registry
      Options +ExecCGI
      PerlSendHeader On
      allow from all
  

Save the modified file.

This configuration causes every URI starting with /perl to be handled by the Apache mod_perl module with the handler from the Perl module Apache::Registry.

Problem with this page? Let us know
© Lee Stretton 2005 | powered by linux powered by php 5 powered by MySQL download rss feeds powered by php 5 valid css