Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2010 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/601896 to your computer and use it in GitHub Desktop.
Save anonymous/601896 to your computer and use it in GitHub Desktop.
Hi,
I just wanted to share my solution. I haven't thoroughly tested it, but it
seems to be working fine with Ivy 2.2.0-rc1. Basically, I added a mod_perl
handler to Apache to catch any PUT requests, extract the full path, create
all the directories, then let it continue its work.
There is definitely some setup. You basically need four things:
1) Apache 2 (I used 2.2.x)
2) Perl (I used ActivePerl 5.10) - Ensure it's in your system PATH for
Apache to pick up!
3) mod_perl for Apache (I installed the ActivePerl 5.10 PPM package from
http://perl.apache.org/docs/2.0/os/wi...html#PPM_Packages)
4) Apache webdav modules (they came standard with my Apache install)
If you haven't clued in yet, I'm using Windows. The requirements are the
same in Linux and UNIX, except where you grab perl, apache, and the perl
module for apache is up to you to figure out. :-P
In your apache base directory create the sub-directory "ApachePerl". In
there create an empty Perl module file called "AutoMKCOL.pm". Edit it and
copy/paste the following:
###########################################################
#
# This is a PerlFixupHandler that will take any PUT
# requests, determine the path required, and if it doesn't
# exist, creates the whole path. If there is a problem
# creating the path, an error is generated.
#
###########################################################
package ApachePerl::AutoMKCOL;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::ServerRec ();
use Apache2::Log ();
use File::Path qw(make_path);
use File::Basename qw(dirname);
# Compile constants
use Apache2::Const -compile => qw(DECLINED);
sub handler {
my $r = shift;
# Create directories if processing a put request.
if ($r->method() eq "PUT")
{
# The full file system path to the file requested is a concat of the
request filename and path_info.
my $fullpath = $r->filename() . $r->path_info();
my $dirname = dirname($fullpath);
# If the directory doesn't exist, create it
if (!(-d $dirname))
{
$r->log->info("Creating directory structure for PUT request: '" .
$dirname . "'.");
my @dirlist = make_path ($dirname);
# If at least one directory wasn't created, there was a problem
die "Failed to create directory structure: '" . $dirname . "'." unless
$#dirlist > -1;
}
}
# Allow next handler to run
return Apache2::Const::DECLINED;
}
1;
Now we turn our attention towards Apache's configuration file
(conf/httpd.conf):
- Ensure the mod_perl module is loaded:
LoadModule perl_module modules/mod_perl.so
- Ensure the webdav modules are loaded:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule dav_lock_module modules/mod_dav_lock.so
Activate WebDav file locking by adding this line near the top:
DavLockDB "/path/to/Apache/DavLock"
In the Directory directive of the path you want to enable the PUT method
(Ivy publishing) add the following:
<Directory "/path/to/Apache/htdocs/ivy/repository">
Dav On
PerlFixupHandler +ApachePerl::AutoMKCOL
</Directory>
And that's about it. Restart Apache and if you did everything right it
should start fine and you can begin publishing with Ivy via the url
resolver. In the httpd.conf file, if you change LogLevel to "debug"
temporarily you will see the messages generated by the perl module and
potentially other messages if you are having problems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment