To start you must pre-configure your Webserver with the Mod_Perl module.
You can obtain a version of Mod_Perl for Apache at http://perl.apache.org/
. Mod_Perl support is only available under the commercial version of
@Mail, the demo version does not include support.
You can run the install.pl script via the command-line to modify your
httpd.conf with support for Mod_Perl with @Mail . Before running the
install.pl script, your webserver must be pre-configured with Mod_Perl.
You can also configure your httpd.conf manually with Mod_Perl and @Mail.
Below is an example configuration to enable @Mail with Mod_Perl support.
# Optional; your Webserver
should already include lines similar to these:
<IfDefine HAVE_PERL>
LoadModule perl_module modules/libperl.so
</IfDefine>
# Optional; your Webserver should already include lines similar to these:
<IfDefine HAVE_PERL>
AddModule mod_perl.c
</IfDefine>
# @Mail Mod_Perl Conf
# If the perl module is installed, this will be enabled.
<IfModule mod_perl.c>
# Optional, only for the SQL version of @Mail
PerlModule Apache::DBI
# For Mod_Perl 1.X
PerlInitHandler Apache::StatINC
# For Mod_Perl 2.X
#PerlInitHandler Apache::Reload
# For SQL version of @Mail
PerlRequire "/www/atmail3/modperldb.pl"
# For Flat-file version of @Mail
#PerlRequire "/www/atmail3/modperlfile.pl"
<Directory "/path/to/atmail/">
<Files ~ ".pl$">
SetHandler perl-script
# For Mod_Perl 1.X
PerlHandler Apache::Registry
# For Mod_Perl 2.X
# PerlHandler ModPerl::Registry
Options +ExecCGI
PerlSendHeader On
</Files>
<Files ~ "spell.pl$">
SetHandler cgi-script
</Files>
# Disable Mod_Perl for the WAP feature (not supported)
<Files ~ "wap.pl$">
SetHandler cgi-script
</Files>
</Directory>
<Directory "/www/atmail3/webadmin">
<Files ~ ".pl$">
SetHandler cgi-script
Options +ExecCGI
</Files>
</Directory>
</IfModule>
Before simply copy and pasting the above into the httpd.conf you must
have a basic understanding what the configuration does.
Each configuration line is described below.
<IfDefine HAVE_PERL>
LoadModule perl_module modules/libperl.so
</IfDefine>
<IfDefine HAVE_PERL>
AddModule mod_perl.c
</IfDefine>
By default the above lines should be already defined in your httpd.conf
when Mod_Perl was installed. The configuration will load the libperl.so
module (created by the Mod_Perl installation) into the Webserver. This
combines the Perl interpreter into the Webserver increasing the performance
of @Mail.
The IfDefine HAVE_PERL definition will activate if the Webserver was
launched with the -DHAVE_PERL argument. You can safely remove the <IfDefine></IfDefine>
if you certain Apache is correctly installed with Mod_Perl
# If the perl module is installed, this will be enabled.
<IfModule mod_perl.c>
...
</IfModule>
The next step begins to configure Apache to use Mod_Perl for the @Mail
application. The <IfModule> tag encapsulates the commands and
will only run if the Mod_Perl library was successfully loaded.
PerlModule Apache::DBI
PerlInitHandler Apache::StatINC
The Apache::DBI line is required only if you are running the SQL version
of @Mail. The module creates a persistent database connection, and avoids
creating a new database handle for each process in @Mail.
The Apache::StatINC will automatically restart the Webserver if a library
in @Mail is modified ( for Mod_Perl 1.X) . Using Mod_Perl 2.X you must
use the definition Apache::Reload
Since Mod_Perl will cache all the @Mail scripts / modules it will
not recognize any changes to the runtime modules until the Webserver
is restarted (For example, changing the configuration of @Mail via the
WebAdmin).
By using Apache::StatINC / Apache::Reload any configuration modules
changed in @Mail will be automatically reloaded.
# For the SQL version of @Mail
PerlRequire "/www/atmail3/modperldb.pl"
Or
# For the Flat file version of @Mail
PerlRequire "/www/atmail3/modperlflat.pl"
This will pre-load the modperldb.pl or modperlflat.pl script into the
parent process in Apache. Depending on your setup choose the corresponding
PerlRequire line. These scripts pre-loaded common library's shared in
@Mail to reduce files re-loading each Apache process.
For running the SQL version of @Mail, each Apache process will open
a mySQL connection to the server. This is required to create a persistent
database connection and speed-up Web-requests from users. By default
mySQL is installed with a limit of the number of open connections (usually
around 50-100) . It is highly recommended you increase this value in
the /etc/my.cnf file to avoid the mySQL server denying new connections.
If you are using Mod_Perl 2.X , the above PerlRequire file must be
modified to include the following module at the top of the document.
use Apache::compat;
This will allow the new Mod_Perl version to correctly run with the
backwards compatability of Mod_Perl 1.X
/etc/my.cnf:
[mysqld]
set-variable = max_user_connections=500
set-variable = max_connections=500
The modperldb.pl or modperlflat.pl script will setup the library path
for Apache::StatINC to recognize the module path in @Mail. The script
will also create the persistent database connection to the SQL server.
<Directory "/www/atmail3/">
<Files ~ ".pl$">
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
PerlSendHeader On
</Files>
<Files ~ "spell.pl$">
SetHandler cgi-script
</Files>
</Directory>
The configuration above sets up the /www/atmail3/ directory with Mod_Perl.
Replace the directory with the full pathname to @Mail installed on your
server.
Any files with the .pl extension in the /www/atmail3/ directory will
be enabled to use Mod_Perl. The webserver will cache the script contents
and setup the Apache::Registry environment to handle the requests.
The spell.pl file is excluded from Mod_Perl since it is not supported.
The script uses an external binary that is not compatible with Mod_perl.
<Directory "/www/atmail3/webadmin">
<Files ~ ".pl$">
SetHandler cgi-script
Options +ExecCGI
</Files>
</Directory>
</IfModule>
The above will disable Mod_Perl from the @Mail WebAdmin. The WebAdmin
is not compatible with Mod_Perl, and can safely be run under normal
CGI mode.
The next step is to configure the @Mail scripts with Mod_Perl support.
Via the command line run the change-lib.pl script with the pathname
to the atmail/libs directory and modperl as the second argument. For
example:
server# cd /path/to/atmail/
server# perl change-lib.pl /path/to/atmail/libs/ modperl
On you have included the Mod_Perl configuration to httpd.conf you can
restart the Webserver using:
apachectl restart
Or kill -HUP the httpd processes on the server.
Once restarted verify the Webserver is starting. Check the Apache ErrorLog
contains the following string:
[notice] Apache/1.3.12 (Unix) (Red Hat/Linux) mod_perl/1.24 configured
-- resuming normal operations
If you see the mod_perl/1.XX configured you have successfully setup
the Webserver with Mod_Perl
The next step is to run the atmail/change-lib.pl script via the command
line to enable Mod_Perl support in the @Mail scripts.
To test the @Mail pages are loading with Mod_Perl visit the index page
within @Mail. For example http://localhost/atmail/index.pl
Once the login page is loaded click View Source in your web-browser.
Towards the end of the HTML file you should see the following comment:
<!-- MOD PERL -->
If you see the text above, congratulations you have successfully installed
Mod_Perl on your webserver with @Mail.