Jump to content

Nova Resource:Wikisource/IA Upload

From Wikitech

This page documents how to set up a VPS for the IA Upload tool in the Wikisource project.

Web server

Install and configure Apache, PHP, ImageMagick, and DjVuLibre.

sudo apt install php php-common php-cli php-fpm php-json php-xml php-intl php-curl php-zip apache2 libapache2-mod-php composer imagemagick djvulibre-bin

Create the web server configuration file at /etc/apache2/sites-available/ia-upload.conf with the following:

<VirtualHost *:80>
        ServerName ia-upload.wmcloud.org
        DocumentRoot /var/www/tool/public
        <Directory /var/www/tool/public/>
             Options Indexes FollowSymLinks
             AllowOverride All
             RewriteEngine On
             RewriteRule ^index\.php$ - [L]
             RewriteCond %{REQUEST_FILENAME} !-f
             RewriteCond %{REQUEST_FILENAME} !-d
             RewriteRule . /index.php [L]

Enable some Apache modules, and the web server configuration (and disable the default site, which isn't used):

sudo a2enmod rewrite
sudo a2ensite ia-upload
sudo a2dissite 000-default
sudo apache2ctl graceful


Set /etc/ImageMagick-6/policy.xml to have the following values (or larger):[1]

  <policy domain="resource" name="memory" value="2GiB"  />
  <policy domain="resource" name="map"    value="2GiB"  />
  <policy domain="resource" name="area"   value="256MB" />


Clone the repository, first removing the html/ directory created by Apache.

cd /var/www
sudo rm -rf html
sudo git clone https://github.com/wikisource/ia-upload.git tool
sudo chown -R www-data:www-data tool

Install dependencies with Composer (this also will create the config.ini file):

cd tool
sudo -- sudo -u www-data composer install --no-dev -o

Create a OAuth 1.0a consumer on Meta Wiki, and add its key and secret to config.ini. Also add its ID, to be used for the recent changes link.


Set up crontab for user `www-data`:

*/12 * * * * /var/www/tool/bin/ia-upload jobs > /dev/null
@daily       /var/www/tool/bin/ia-upload prune

Data volume

The job queue is stored on a volume, mounted at /ia-upload and symlinked to the tool's directory:

$ sudo ln -s /ia-upload/jobqueue /var/www/tool/jobqueue
  1. See also Phabricator:T335332