Tuesday, 25 July 2017

More NewzNab Stuff

My Raspberry Pi running NewzNab is suffering, it really hasn't got enough power even when running from an SSD so I',m putting an old laptop back into use and I'm going to get NewzNab running on Ubuntu 16.04, it's not worked before due to changes in php but I've found some new instructions which didn't work so I modified them and put together some of my own.

I'm writing this article as I setup the server itself, I won't go into how to install Ubuntu 16.04 server, you should be able to do that yourself, the only package I'm going to add initially during the install is SSH server so I can do the rest of the install remotely.

I'm also setting up my router to assign a static IP and forwarding on the relevant ports so I can access the server from outside the house. Again, this is something I'm not covering here due to the different ways to do this on different routers.

Once the initial install has finished it's time to ssh into the server with:

ssh servername

And then we'll get started with some updates and installation of the required packages.

sudo -s

apt update && apt upgrade

apt install ssh screen apache2 php mysql-server libapache2-mod-php php-pear php-gd php-mysql php-curl php-json unrar lame mediainfo subversion ffmpeg memcached mc nfs-common -y


Once that's all finished we will tighten up the SQL security with this:

mysql_secure_installation

Now it's time to create the SQL database:

mysql -u root -p

CREATE DATABASE newznab;

exit

And then we edit the mysql config

nano /etc/mysql/conf.d/mysql.cnf

Add the following to the bottom

[mysqld]
group_concat_max_len=8192
innodb_flush_log_at_trx_commit = 2

Save that and then edit this file

nano /etc/mysql/my.cnf

Add this to the bottom

[mysqld]
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"



Now we make the directory structure:

mkdir /var/www/newznab
mkdir /var/www/newznab/htdocs
mkdir /var/www/newznab/logs

Now it's time to get Newznab, you can get it here, I suggest you get the paid version, it's cheap and it's much better and these instructions are written with it in mind.

We're going to make an update script that once completed will install the latest version of Newznab when run, we start this with:

nano /var/www/newznab/svn.sh

Paste this lot in replacing the starts with the username and password you got when you signed up for Newznab.

svn export --no-auth-cache --force --username **** --password **** svn://svn.newznab.com/nn/branches/nnplus /var/www/newznab/htdocs/

#rm /var/www/newznab/htdocs/*.txt
#rm -rf /var/www/newznab/htdocs/www/install
#rm -rf /var/www/newznab/htdocs/www/lib/smarty/templates_c/*

cd /var/www/newznab/htdocs/misc/update_scripts
php update_database_version.php
cd /var/www/newznab/htdocs

service memcached restart
service apache2 restart

Now we make it executable with:

chmod +x /var/www/newznab/svn.sh

And then run it with:

/var/www/newznab/svn.sh

Now we make sure all the directories are writeable:

chmod 777 /var/www/newznab/htdocs/www/lib/smarty/templates_c
chmod 777 /var/www/newznab/htdocs/www/covers/movies
chmod 777 /var/www/newznab/htdocs/www/covers/anime
chmod 777 /var/www/newznab/htdocs/www/covers/music
chmod 777 /var/www/newznab/htdocs/www/covers/tv
chmod 777 /var/www/newznab/htdocs/www
chmod 777 /var/www/newznab/htdocs/www/install
chmod -R 777 /var/www/newznab/htdocs/nzbfiles/

And then make a config for Apache to use

nano /etc/apache2/sites-available/newznab.conf

Paste this into it:

<VirtualHost *:80>
    <Directory /var/www/newznab/htdocs/www/>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    DocumentRoot /var/www/newznab/htdocs/www
    ErrorLog /var/www/newznab/logs/error.log
    CustomLog /var/www/newznab/logs/access.log combined
</VirtualHost>

You can change the port in the top line to something else if you want but you have to add a line to

etc/apache2/ports.conf

That says

Listen 8080 or whatever port you choose.

Now some config file changes with:

nano /etc/php/7.0/apache2/php.ini

Find these values and change them as shown below, they are listed in order:

max_execution_time = 120
memory_limit = -1
date.timezone = 'Europe/London'

Now we activate the server and deactivate the default one with:

a2dissite 000-default.conf
a2ensite newznab
a2enmod rewrite
service apache2 restart
service mysql restart

We can now uncomment some lines from an earlier file

nano /var/www/newznab/svn.sh

Remove the # from these lines

#rm /var/www/newznab/htdocs/*.txt
#rm -rf /var/www/newznab/htdocs/www/install
#rm -rf /var/www/newznab/htdocs/www/lib/smarty/templates_c/*

And then run it to get any updates:

/var/www/newznab/svn.sh

Now point your browser to:

http://server:port to finish setting up Newznab itself

Once you've finished the initial setup, go the admin section and click on edit site, find these options and change the values to the ones shown below.

default home page : /browse
newznabID : <provided in signup email>
unrar path : /usr/bin/unrar
mediainfo path : /usr/bin/mediainfo
ffmpeg path : /usr/bin/ffmpeg
lame path : /usr/bin/lame
integrated cleanup : yes
save audio preview : yes
check for password : deep
delete passworded releases : yes


Activate one group, probably alt.binaries.teevee

Then let's try running an update


cd /var/www/newznab/htdocs/misc/update_scripts
php update_binaries.php
php update_releases.php

Once completed you should see some articles appearing

There's a lot more information here on how to get Newznab running to continuously pull updates here, the one thing that you shouldn't do is use a cron job.