The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache::FileManager - Apache file manager

SYNOPSIS

Install in mod_perl enabled apache conf file <Location /FileManager> SetHandler perl-script PerlHandler Apache::FileManager </Location>

Or call from your own mod_perl script use Apache::FileManager; my $obj = Apache::FileManager->new(); $obj->print();

DESCRIPTION

The Apache::FileManager module is a simple HTML file manager. It provides file manipulations such as cut, copy, paste, delete, rename, extract archive, create directory, and upload files. All of these can be enacted on one or more files at a time (except rename). This module requires the client to have Java-script, and cookies enabled.

The Apache::FileManager also can be used for a development site. The document tree can then be copied to the production server with the click of a button in the File Manager via an rsync. If this functionality is wanted, you must also install File::Rsync.

SPECIAL NOTES

Make sure the web server has read, write, and execute access access to the directory you want to manage files in. Typically you are going to want to run the following commands before you begin.

chown -R nobody /web/xyz/htdocs chmod -R 755 /web/xyz/htdocs

The extract functionality only works with tarballs and zips. Is there demand for anything else?

RSYNC FEATURE

Warning! rsync will delete files on the production server that do not exist on the development server for the directory specified on the production server specified by the RSYNC_TO directive.

To use the rync functionality you must have ssh, rsync, and the File::Rsync perl module installed on the development server. You also must have an sshd running on the production server.

Make sure you always fully qualify your server names so you don't have different values in your known hosts file. for example: ssh my-machine - wrong ssh my-machine.subnet.com - right

Note: if the ip address of the production_server changes you will need a new known_hosts file.

To get the rsync feature to work do the following:

  #1 log onto the production server

  #2 become root

  #3 give web server user (typically nobody) a home area
     I made mine /usr/local/apache/nobody
     - production_server> mkdir /usr/local/apache/nobody
     - edit passwd file and set new home area for nobody
     - production_server> mkdir /usr/local/apache/nobody/.ssh

  #4 log onto the development server

  #5 become root

  #6 give web server user (typically nobody) a home area
     - dev_server> mkdir /usr/local/apache/nobody
     - dev_server> chown -R nobody.nobody /usr/local/apache/nobody
     - edit passwd file and set new home area for nobody
     - dev_server> su - nobody
     - dev_server> ssh-keygen -t dsa      (don't use passphrase)
     - dev_server> ssh production_server (will fail but will make known_hosts file)
     - log out from user nobody back to root user
     - dev_server> cd /usr/local/apache/nobody/.ssh
     - dev_server> scp id_dsa.pub production_server:/usr/local/apache/nobody/.ssh/authorized_keys
     - dev_server> chown -R nobody.nobody /usr/local/apache/nobody
     - dev_server> chmod -R 700 /usr/local/apache/nobody

  #7 log back into the production server

  #8 become root

  #9 Do the following commands:
     - production_server> chown -R nobody.nobody /usr/local/apache/nobody
     - production_server> chmod -R 700 /usr/local/apache/nobody

You also need to specify the production server in the development server's web conf file. So your conf file should look like this:

     <Location /FileManager>
       SetHandler           perl-script
       PerlHandler          Apache::FileManager
       PerlSetVar           RSYNC_TO   production_server:/web/xyz/htdocs
     </Location>

If your ssh path is not /usr/bin/ssh or /usr/local/bin/ssh, you also need to specify the path in the conf file or in the contructor with the directive SSH_PATH.

You can also specify RSYNC_TO in the constructor: my $obj = Apache::FileManager->new({ RSYNC_TO => "production_server:/web/xyz" });

Also make sure /web/xyz and all files in the tree are readable, writeable, and executable by nobody on both the production server AND the development server.

BUGS

I am sure there are some.

TODO

It would be nice if you could choose a different base directory other then the document root in the constructor. I may do this sometime if I have a need to. If you want to contribute, send me your updates.

AUTHOR

Apache::FileManager was written by Philip Collins <pmc2@sr.unh.edu>.