Red Antigua Logo
Yet another piece of web.
Search this site (by Google)
Tools    (top)
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
MSYS2 - UNIX environment for MS Windows 32/64 bits
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

mod_perl on FreeBSD
mod_perl on FreeBSD
Install mod_perl2 (also installs Apache2 if not installed already):
cd /usr/ports/www/mod_perl2/
make install clean
Edit /usr/local/etc/apache2/httpd.conf:
Enable mod_perl built as DSO...
LoadModule perl_module libexec/apache2/mod_perl.so
... and tell Perl where to find mod_perl2 libraries...
PerlModule Apache2
... and always turn on warnings and taint mode (which you always do anyway with your CGI scripts, don't you?)...
PerlSwitches -wT
... and finally add the following section to configure Apache for registry scripts:
Alias /perl/ /usr/local/www/perl/
<Location /perl/>
    SetHandler perl-script
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    Options +ExecCGI
</Location>
Create the directory for mod_perl registry scripts:
mkdir /usr/local/www/perl
Restart Apache, check the error log for possible errors:
/usr/local/etc/rc.d/apache2.sh restart
tail /var/log/httpd-error.log
Test the installation.
Create a test script /usr/local/www/perl/helloworld.pl:
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "Hello, world!\n";
Set executable permissions:
chmod 755 /usr/local/www/perl/helloworld.pl
Test http://localhost/perl/helloworld.pl from your local browser.

If you see the famous 'Hello, world!', congratulations.
If not, check the error log for possible errors:
tail /var/log/httpd-error.log


Sooner or later you will probably use the CGI.pm module.
As indicated here, you need CGI.pm version 3.08 or newer - versions 3.07 and older do not support the new mod_perl API.
Check your CGI.pm version from the command line:
perl -e 'use CGI; print CGI->VERSION, "\n";'
3.10
If update is needed:
cd /usr/ports/www/p5-CGI.pm
make install clean

Read more at:
http://perl.apache.org/docs/2.0/user/intro/start_fast.html
http://perl.apache.org/docs/2.0/user/config/config.html
Last modified: Mon Mar 26 10:26:20 Romance Daylight Time 2007