Apache2-WebApp-Toolkit
view release on metacpan or search on metacpan
$ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib
$ make
$ make test
$ make install
Perl one liner using CPAN.pm:
$ perl -MCPAN -e 'install Apache2::WebApp'
Use of CPAN.pm in interactive mode:
$ perl -MCPAN -e shell
cpan> install Apache2::WebApp
cpan> quit
Just like the manual installation of Perl modules, the user may need
root access during this process to insure write permission is allowed
within the installation directory.
GETTING STARTED
HELPER SCRIPTS
Create a new project
$ webapp-project --project_title Project --apache_doc_root /var/www
or
$ webapp-project --config /path/to/conf/webapp.conf
Export project settings to the Unix shell
$ source /path/to/project/.projrc
Create a new class
$ webapp-class --name ClassName
Add a pre-packaged *Extra* to an existing project
$ webapp-extra --install PackageName
Start your application
$ webapp-kickstart
Standard output
/var/www/project/app <-- A
/var/www/project/app/Project
/var/www/project/app/Project/Base.pm <-- B
/var/www/project/app/Project/Example.pm <-- C
/var/www/project/bin
/var/www/project/bin/startup.pl <-- D
/var/www/project/conf
/var/www/project/conf/htpasswd <-- E
/var/www/project/conf/httpd.conf <-- F
/var/www/project/conf/webapp.conf <-- G
/var/www/project/htdocs <-- H
/var/www/project/templates/example.tt <-- I
/var/www/project/templates/error.tt <-- J
/var/www/project/logs <-- K
/var/www/project/logs/access_log
/var/www/project/logs/errror_log
/var/www/project/tmp <-- L
/var/www/project/tmp/cache
/var/www/project/tmp/cache/templates
/var/www/project/tmp/uploads
A) Application directory. All classes *(*.pm)* within this directory are
precompiled into memory when Apache starts/restarts.
B) Base class that can be "included" from other classes. Contains
"_global()" and "_error()" methods that can be inherited using:
Example:
use base 'Project::Base';
C) Basic class.
D) This is executed when the Apache server starts. It's used to reset
Perl module search paths in @INC, preload web application classes,
precompile constants, etc.
Example:
#!/usr/bin/env perl
$ENV{MOD_PERL} or die "Not running under mod_perl";
use lib '/var/www/project/app';
..
# Modules added here will be URI accessible
__DATA__
Project::Foo
Project::Foo::Bar
E) Password file used for restricting access to a specified path (see
"httpd.conf").
The login information below is currently set-up by default.
User Name admin
Password password
You can change the login password using the "htpasswd" command-line
script.
$ htpasswd /var/www/project/conf/htpasswd admin
F) Apache server *Virtual Host* configuration.
G) Application configuration. This file contains your project settings.
Due to security reasons, this file should always remain outside the
*/htdocs* directory path.
Example:
[project]
title = Project # must not contain spaces or special characters
author = Your Name Here
email = email@domain.com
version = 0.01
[apache]
doc_root = /var/www/project # path to project directory
domain = www.domain.com # valid domain name
disable_uploads = 0 # allow file uploads
post_max = 5242880 # post max in bytes (example 5MB)
temp_dir = /var/www/project/tmp/uploads
[template]
cache_size = 100 # total files to store in cache
compile_dir = /var/www/project/tmp/cache/templates # path to template cache
include_path = /var/www/project/templates # path to template directory
stat_ttl = 60 # template to HTML build time (in seconds)
encoding = utf8 # template output encoding
H) Website sources. This includes HTML, CSS, Javascript, and images.
When setting up FTP access - restrict access to this directory only.
I) Basic template.
J) Application error templates.
K) Apache log directory that contains both access and error logs. Due to
security reasons, this directory should always remain outside the
*/htdocs* directory path.
L) Temporary shared space for file processing.
CAVEATS
Since your classes get compiled at Apache start-up the server must be
restarted when any code changes take place. You can do this easily using
the "webapp-kickstart" script provided with this package.
WARNING
In Perl, variables do not need to be declared and are by default
globally scoped. The issue with *mod_perl* is that global variables can
persist between requests. To avoid this problem, you should always have
the following line in your code:
use strict;
SEE ALSO
perl(1), mod_perl(2), Apache(2), Apache2::Request, Apache2::RequestRec,
Apache2::RequestUtil, Apache2::Connection, Apache2::Upload,
Apache2::Const, Apache2::Log
AUTHOR
Marc S. Brooks, <mbrooks@cpan.org> - <http://mbrooks.info>
COPYRIGHT
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See <http://dev.perl.org/licenses/artistic.html>
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
( run in 1.347 second using v1.01-cache-2.11-cpan-b16cb0d3907 )