How to install Spotweb and automatically populate the database.

17 Dec

Spotweb can be a bit of a pain to setup (especially the initial database population). Below I’ll explain how to get things running properly.

The instructions below you assume you have setup an Apache2, PHP, and MariaDB server.

Create a directory in which we’ll store the Spotweb site:

mkdir -p /var/vhosts/domain-name/www

Download and install the latest release of Spotweb:

cd /tmp
wget https://github.com/spotweb/spotweb/archive/1.3.9.tar.gz
tar xzf 1.3.9.tar.gz
cd spotweb-1.3.9
cp * -R /var/vhosts/domain-name/www

Create an Apache configuration file for Spotweb:

nano /etc/apache2/sites-available/domain-name.conf

Populate with the settings below (assumes SSL):

<VirtualHost 0.0.0.0:80>
ServerName domain-name
 
Redirect / https://domain-name/
 
</VirtualHost>
 
<VirtualHost *:443>
ServerName domain-name
 
SSLEngine on
 
SSLCertificateFile /var/vhosts/domain-name/ssl/domain-name.crt
SSLCertificateKeyFile /var/vhosts/domain-name/ssl/domain-name.key
SSLCertificateChainFile /var/vhosts/domain-name/ssl/ca-cert.crt
 
DocumentRoot "/var/vhosts/domain-name/www"
 
<Directory />
AllowOverride All
Require all granted
</Directory>
 
</VirtualHost>

ExpiresActive On
ExpiresDefault "access plus 4 hours"
ExpiresByType application/javascript A900
ExpiresByType application/x-javascript A900
ExpiresByType text/javascript A900
ExpiresByType text/html A90
ExpiresByType text/xml A90
ExpiresByType text/css A900
ExpiresByType text/plain A62
ExpiresByType image/gif A14400
ExpiresByType image/jpg A14400
ExpiresByType image/jpeg A14400
ExpiresByType image/png A14400
ExpiresByType image/bmp A14400
ExpiresByType application/x-shockwave-flash A3600

Enable the newly created site:

a2ensite domain-name.conf

Enable the Apache module expires (this allows the ExpiresActive On command to work):

a2enmod expires

Spotweb requires a few additional PHP modules, we need to download and enable them:

apt-get install php-curl php-zip php-xml php-gd

To ensure Spotweb uses the proper date and time we need to define our timezone in PHP (used by Apache):

nano /etc/php/7.0/apache2/php.ini
date.timezone = America/Edmonton

To ensure Spotweb uses the proper date and time we need to define our timezone in PHP (used by the command line):

nano /etc/php/7.0/cli/php.ini
date.timezone = America/Edmonton

Because our Spotweb Apache configuration file has the AllowOverride All directive, we can create an .htaccess file which will allow other scripts (Sonarr, Radarr, and Lidarr) to perform lookups:

nano /var/vhosts/domain-name/www/.htaccess

Populate as required:

RewriteEngine on
RewriteCond %{REQUEST_URI} !api/
RewriteRule ^api/?$ index.php?page=newznabapi [QSA,L]

Now we need to change the owner of the Spotweb directory:

chown -R www-data:www-data /var/vhosts/domain-name

Restart Apache:

service apache2 restart

Complete the setup of Spotweb using a browser:

https://domain-name/install.php

After Spotweb is configured delete the installation file:

rm /var/vhosts/domain-name/www/install.php

Now we can populate Spotweb via the CLI:

php /var/vhosts/domain-name/www/retrieve.php

I typically run the above command on the console as it can take a few hours to complete.

Create a directory in which log files will be saved:

mkdir /var/vhosts/domain-name/log

Perform an ownership change (as any downloaded content and directories created was done by the user root and not www-data):

chown -R www-data:www-data /var/vhosts/domain-name

Create a cron job (scheduled task) for the user www-data. This allows Spotweb to self-update:

crontab -u www-data -e

In the example below the cron job will execute every 30 minutes:

*/30 * * * * /usr/bin/php /var/vhosts/domain-name/www/retrieve.php >> /var/vhosts/domain-name/log/retrieve.log

Leave a Reply

Your email address will not be published.