Installing PDFpirate on Debian 5 (Lenny)
This instruction is written for PDFpirate version 0.3; notice that it may, and probably will, change with the subsequent releases. For older versions check the following: v0.2
Getting the files
To get PDFpirate files use git. You may need to install the git command first by issuing apt-get install git-core.
git clone git://community.pdfpirate.org/pdfpirate.git
cd pdfpirate/
git archive --format=tar --prefix=PDFpirate-0.3/ v0.3 | (cd .. && tar xf -)
Installing PDFpirate
Now recursively copy all the files from ../PDFpirate-0.3/www/ to the directory from where they'll be served by Apache2. You'll also have to create a storage/ folder writable by Apache2 processes.
mkdir -p /srv/www/pdfpirate
cp -r ../PDFpirate-0.3/www/* /srv/www/pdfpirate
mkdir /srv/www/pdfpirate/storage
chown www-data:www-data /srv/www/pdfpirate/storage
Installing required packages
To run PDFpirate you'll need to install few packages that don't come pre-installed with a standard Debian setup.
apt-get install libapache2-mod-apreq2 libapache2-mod-perl2 libapache2-request-perl libhtml-mason-perl libfile-type-perl ghostscript
You'll also need to install wkhtmltopdf which is currently absent from Debian repositories. Please adjust the download path below to suit your architecture. The list of available options is here.
wget -O- http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2 | sudo tar -xjf - --directory=/usr/local/bin
Configuring Apache2
First create a /etc/apache2/sites-available/pdfpirate file and copy below code into it.
<VirtualHost 127.0.0.1:80>
## General
ServerAdmin www-admin_AT_pdfpirate_DOT_org
DocumentRoot /srv/www/pdfpirate
ServerName pdfpirate.org
## Logging
ErrorLog /var/log/apache2/pdfpirate_error.log
LogLevel warn
CustomLog /var/log/apache2/pdfpirate_access.log combined
## Mason specific settings
# Preload perl modules to shared memory
PerlModule HTML::Mason::ApacheHandler
PerlModule Apache2::Request
PerlModule Apache2::Connection
PerlModule Apache2::Upload
PerlModule Apache2::Const
PerlModule Apache2::Cookie
PerlModule Apache2::RequestRec
PerlModule APR::UUID
PerlModule File::Type
PerlModule File::Path
PerlModule Encode
# Set up mason variables
PerlSetVar MasonPreamble "use utf8;"
PerlSetVar MasonDataDir /tmp/pdfpirate
PerlSetVar MasonErrorMode fatal
PerlSetVar MasonInPackage pdfpirate
PerlSetVar MasonArgsMethod mod_perl
PerlSetVar MasonAllowGlobals %strings
PerlAddVar MasonAllowGlobals %config
PerlAddVar MasonAllowGlobals $language
PerlAddVar MasonAllowGlobals $language_subtag
PerlAddVar MasonAllowGlobals $text_direction
## Default settings for all directories
<Directory /srv/www/pdfpirate>
# Serve html files through Mason
<FilesMatch "(\.html|\.js)$">
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</FilesMatch>
# Hide private components (Mason)
<FilesMatch "(\.mhtml|dhandler|autohandler|pdfpirate.config)$">
SetHandler perl-script
PerlHandler "sub { use Apache2::Const -compile => qw(NOT_FOUND); return Apache2::Const::NOT_FOUND; }"
</FilesMatch>
# Access policy
Order deny,allow
Allow from all
# Switch directory listings off
Options -Indexes
</Directory>
## Settings for /lib directory
<Directory /srv/www/pdfpirate/lib>
# Don't handle files in /lib in any special way (switches Mason off for this directory)
<FilesMatch ".*">
SetHandler None
</FilesMatch>
</Directory>
</VirtualHost>
Now edit the /etc/apache2/sites-available/pdfpirate file and adjust the options according to your server setup. Notice that only standard Apache2 options really require your attention. Rest, if unsure, may be left as it is.
Enable apreq module.
a2enmod apreq
To activate PDFpirate create a symbolic link within /etc/apache2/sites-enabled/ directory and point it at the /etc/apache2/sites-available/pdfpirate file, then restart Apache2. The XXX in the example below is a website's starting order number, replace it with whatever number you wish.
cd /etc/apache2/sites-enabled/
ln -s ../sites-available/pdfpirate XXX-pdfpirate
/etc/init.d/apache2 restart
That's all. You can now access your local PDFpirate setup with a web browser.