Wednesday, 16 April 2014

Newznab Server on Debian

I've put this together with help from a few other websites, it's pretty much the same as an Ubuntu install but with a few slight differences.

All the following stuff is done via ssh terminal and you can copy and paste the commands in to make life easier.

If you are doing this on a fresh install of Debian, you need to edit the sources.list file with:

nano /etc/apt/sources.list

Add contrb non-free to the end of the lines as shown below.

deb wheezy main contrib non-free
deb-src wheezy main

deb wheezy/updates main contrib non-free
deb-src wheezy/updates main

# wheezy-updates, previously known as 'volatile'
deb wheezy-updates main contrib non-free
deb-src wheezy-updates main

Add this entry to the bottom of the list:

deb jessie main non-free

Save it and then run:

apt-get update
apt-get install deb-multimedia-keyring
apt-get update
apt-get upgrade

Now let's get on with the rest.

mkdir /var/www
mkdir /var/www/newznab
chmod 0777 /var/www/newznab

Next we need to install php with the following:

apt-get install php5 php5-dev php-pear php5-gd php5-mysql php5-curl mc subversion

Now we make some changes to the php configuration file:

nano /etc/php5/cli/php.ini

Under the resource limits section we need to change the maximum execution time to 120:

max_execution_time = 120

Then under Module Settings we need to change the time zone settings, in my case I'm the UK so I'm going to change it to:

date,timezone = Europe/London

There are other options depending on where you live, you can find these here.

Now it's time to install SQL and Apache, so we enter the following command:

apt-get install mysql-server-5.5 mysql-client-5.5 libmysqlclient-dev apache2

During the install process, you will be asked to create a password for the database, if you are going to make this publicly available, you need to make it a good password.

Let's finish off the SQL installation with the following:

Once this has all finished, we then need to make some changes to the Apache config file:

nano /etc/php5/apache2/php.ini

We then need to change these settings

  • memory_limit =  -1
  • max_execution_time = 120 
  • date.timezone =  Europe/London
Now we need to create a configuration file for Newznab, so type the following to create an empty file:

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

And then paste the following into the file, you can use another port instead of 8080 if you want:

<VirtualHost *:8080>
ServerAdmin webmaster@localhost
ServerName localhost

DocumentRoot /var/www/newznab/www
ErrorLog /var/log/apache2/error.log
LogLevel warn

This will run Newznab on port 8080, I want to keep the default port 80 for other things.

We now need to get hold of Newznab itself, you can get it from here. Newznab classic works but there are some limitations, if you are serious just pay the money for a better product and you get free upgrades too.

Get the file downloaded and then we need to extract it and copy it to the right place, if you have decided to use a graphical desktop you can follow these pictures.

As I have a paid for version I'm going to use a slightly different approach, we installed subversion earlier do we get NewNab with.

svn co svn:// /var/www/newznab

At this point you will be asked for the root password for your system and the SVM login details that have been emailed to you by the Newznab team.

We now need to edit an Apache file to it listens to port 8080 for requests, enter the following command:

nano /etc/apache2/ports.conf

Under the line that says Listen 80 we add another line that says:

Listen 8080

Save that file and then one more change to the Apache configuration files before we go on:

nano /etc/apache2/apache2.conf

Find this bit

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

And change it to this:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

Now let's get it all working.

a2ensite newznab
a2enmod rewrite
service apache2 restart

Now it's time to change some permissions with the following commands:

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

We just need to make sure that some files are also installed:

apt-get update
apt-get install unrar mediainfo ffmpeg lame

When you run the Newznab config and go in to edit the site you will need to put the paths in for these files, they normally are:


And now point your browser to 


And just follow the instructions and prompts to configure your very own Newznab server.

Once you have finished the comfiguration, run this following command to change permissions on one of the folders.

chmod 777 /var/www/newznab/nzbfiles/tmpunrar

Once that's all completed, go to the View Groups option and make some groups active.
Then it's back to the command line with

cd  /var/www/newznab/misc/update_scripts

Then run 

php update_binaries_threaded.php

after that it's

php update_releases.php 

That should start populating the indexer, it's up to you how you want to run this, you can it manually but I run a loop with a 10 minute pause each time it restarts.

I've made a file with 

nano /bin/newznabrun

Put this into it

while :

# Beginning Update
cd /var/www/newznab/misc/update_scripts/
php update_binaries_threaded.php
php update_releases.php

        echo "Press [CTRL+C] to stop.."
        sleep 360


Save the file and then run

chmod +x /bin/newznabrun 

You can then type newznabrun to get it going.

That's it all done, hope it all works for you.

I would like to thank the howtogeek website for helping with most of these instructions.