Installing TenderWarehouse (UK) on Debian 5 (Lenny)
This instruction is written for TenderWarehouse (UK) version 0.8; notice that it may, and probably will, change with the subsequent releases.
Getting the files
To get TenderWarehouse (UK) files use git. You may need to install the git command first by issuing apt-get install git-core.
git clone git://community.tenderwarehouse.org/tenderwarehouse_UK.git
cd tenderwarehouse_UK/
git archive --format=tar --prefix=TenderWarehouse_UK-0.8/ v0.8 | (cd .. && tar xf -)
Installing TenderWarehouse (UK)
Now recursively copy all the files from ../TenderWarehouse_UK-0.8/www/ to the directory from where they'll be served by Apache2. You'll also have to make tenders/media and images/captcha folders and its subfolders writable by Apache2 processes.
mkdir -p /srv/www/tenderwarehouse_UK
cp -r ../TenderWarehouse_UK-0.8/www/* /srv/www/tenderwarehouse_UK
chown -R www-data:www-data /srv/www/tenderwarehouse_UK/tenders/media
chown -R www-data:www-data /srv/www/tenderwarehouse_UK/images/captcha
Installign Autch::Captcha
Install Autch::Captcha module from Debian repositories.
apt-get install libauthen-captcha-perl
Apply Captcha patches from dev/patches directory.
patch -i Captcha.pm.diff /usr/share/perl5/Authen/Captcha.pm
patch -i Captcha_secret.pm.diff /usr/share/perl5/Authen/Captcha.pm
Now make a dynamic data directory for this module and have it writable by Apache2 processes.
mkdir -p /var/lib/captcha/tenderwarehouse_UK
chown -R www-data:www-data /var/lib/captcha/tenderwarehouse_UK
Installign Geo::Postcode
Install Geo::Postcode module from Debian repositories.
apt-get install libgeo-postcode-perl
Apply Postcode.pm.diff patch from dev/patches directory.
patch -i Postcode.pm.diff /usr/share/perl5/Geo/Postcode.pm
Installing required packages
To run TenderWarehouse (UK) you'll need to install few extra 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 libemail-valid-perl libtext-template-perl libemail-simple-perl libemail-simple-creator-perl libemail-send-perl liburi-perl libdigest-sha1-perl perlmagick libhtml-parser-perl libhtml-tagfilter-perl libcrypt-cbc-perl libcrypt-blowfish-perl libdatetime-perl libjson-perl postgresql libdbd-pg-perl libapache-dbi-perl libmagic-dev imagemagick libwww-shorten-perl
Installing CPAN modules
Perl modules missing from Debian repositories will have to be isntalled via CPAN.
cpan
cpan[1]> install Number::Compare::Date
cpan[2]> install DateTime::Format::Atom
cpan[3]> install Net::Twitter
Installing database
Postgresql is the database of choice for TenderWarehouse project. First crate a new database user account.
psql -U postgres postgres
CREATE USER tw;
Now create database tenderwarehouse_uk.
createdb -U postgres -O tw tenderwarehouse_uk
Grant the necessary access rights to user tw.
psql -U postgres tenderwarehouse_uk
GRANT ALL PRIVILEGES ON DATABASE tenderwarehouse_uk TO tw;
From dev directory run the below command to create tables.
psql -U tw tenderwarehouse_uk < tenderwarehouse_DB.schema
Finally populate the tables. From dev directory run.
./load_categories.pl tenderwarehouse_uk data/categories
./populate_postcode_locations.pl
Configuring Apache2
First create a /etc/apache2/sites-available/tenderwarehouse_uk file and copy below code into it.
<VirtualHost 127.0.0.1:80>
## General
ServerAdmin www-admin_AT_uk.tenderwarehouse_DOT_org
DocumentRoot /srv/www/tenderwarehouse_UK
ServerName uk.tenderwarehouse.org
## Logging
ErrorLog /var/log/apache2/tenderwarehouse_UK_error.log
LogLevel warn
CustomLog /var/log/apache2/tenderwarehouse_UK_access.log combined
## Mason specific settings
# Preload perl modules to shared memory
PerlModule HTML::Mason::ApacheHandler
PerlModule Apache2::Request
PerlModule Apache2::Upload
PerlModule Apache2::Const
PerlModule Apache2::Cookie
PerlModule Apache::DBI
PerlModule Authen::Captcha
PerlModule Email::Valid
PerlModule Geo::Postcode
PerlModule Geo::Postcode::Location
PerlModule Text::Template
PerlModule Email::Simple
PerlModule Email::Simple::Creator
PerlModule Email::Send
PerlModule APR::UUID
PerlModule URI
PerlModule URI::Escape
PerlModule Digest::SHA1
PerlModule File::Type
PerlModule Image::Magick
PerlModule HTML::Parser
PerlModule HTML::TagFilter
PerlModule Number::Compare::Date
PerlModule Apache2::SubProcess
PerlModule Encode
PerlModule Crypt::CBC
PerlModule Crypt::Blowfish
PerlModule DateTime
PerlModule DateTime::Format::Atom
PerlModule JSON
# Set up mason variables
PerlSetVar MasonPreamble "use utf8;"
PerlSetVar MasonDataDir /tmp/tenderwarehouse_uk
PerlSetVar MasonErrorMode fatal
PerlSetVar MasonInPackage TenderWarehouse::UK
PerlSetVar MasonArgsMethod mod_perl
PerlSetVar MasonAllowGlobals $dbh
PerlSetVar secret 'put_some_random_string_here'
PerlAddVar MasonAllowGlobals $User_ID
PerlAddVar MasonAllowGlobals %strings
## Keep the DB connection alive
<Perl>
Apache::DBI->connect_on_init('dbi:Pg:dbname=tenderwarehouse_uk', 'tw', '');
Apache::DBI->setPingTimeOut('dbi:Pg:dbname=tenderwarehouse_uk', 0);
</Perl>
## Default settings for all directories
<Directory /srv/www/tenderwarehouse_UK>
# Serve html files through Mason
<FilesMatch "\.(html)$">
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</FilesMatch>
# Hide private components (Mason)
<FilesMatch "(\.mas|handler|strings.db)$">
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>
</VirtualHost>
Now edit the /etc/apache2/sites-available/tenderwarehouse_uk file and adjust the options according to your server setup. Notice that only standard Apache2 options and the value of the secret variable require your attention. Rest, if unsure, may be left as it is.
Enable apreq module.
a2enmod apreq
To activate TenderWarehouse (UK) create a symbolic link within /etc/apache2/sites-enabled/ directory and point it at the /etc/apache2/sites-available/tenderwarehouse_uk 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/tenderwarehouse_uk XXX-tenderwarehouse_uk
/etc/init.d/apache2 restart
Configuring TenderWarehouse (UK)
Edit /srv/www/tenderwarehouse_UK/lib/strings.db file to further tweak TenderWarehouse (UK) specific options. If unsure leave it as it is.
Installing bin files
TenderWarehouse (UK) uses few non standard scripts that have to be copied to /usr/local/bin. From bin directory issue the following command.
cp * /usr/local/bin
That's all. You can now access your local TenderWarehouse (UK) setup with a web browser.