Newznab on Ubuntu 22.04 — Newznab 0.2.3-dev documentation (2024)

This guide will help you install everything you need to get Newznab+ running on a fresh Ubuntu 22.04 server. At the end are optional sections for installing elastic search and to configure scripts to allow newznab to continually run. Since 20.04, Apache web server runs by default in mpm_event mode - this requires php to run as a separate fastcgi service known as fpm.

Step 1: Install required packages

Enter the following:

sudo -sapt update && apt upgradeapt install ssh screen apache2 php mariadb-server php-fpm -yapt install php-pear php-gd php-mysql php-redis php-curl php-json php-mbstring unrar lame mediainfo subversion ffmpeg redis memcached -y

Step 2: Configure maria-mysql

Enter the following:

mysql_secure_installation

Note

You will be asked to create a password for the DB server root user.

Create a mysql user for the application:

mysql -u root -p<enter password>CREATE USER 'newznab'@'localhost' IDENTIFIED BY 'password';GRANT ALL PRIVILEGES ON newznab.* TO 'newznab'@'localhost' WITH GRANT OPTION;exit

Edit the mysql configuration file as follows:

pico /etc/mysql/conf.d/mysql.cnf

Add a new section as follows:

[mysqld]group_concat_max_len=8192innodb_flush_log_at_trx_commit = 2

Step 3: Create web directories

Enter the following:

mkdir /var/www/newznabmkdir /var/www/newznab/htdocsmkdir /var/www/newznab/logs

Step 4: Create a script for keeping newznab up to date

Enter the following:

Paste the following into the file, entering the username and password provided after purchasing newznab inplace of the asterix:

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_scriptsphp update_database_version.phpcd /var/www/newznab/htdocssystemctl restart memcachedsystemctl restart apache2systemctl restart php8.1-fpm

Make the file executable and run it:

chmod +x /var/www/newznab/svn.sh/var/www/newznab/svn.sh 2> /dev/null

Step 5: Setup website

Ensure web directories are writeable by the update scripts and installer:

chmod 777 /var/www/newznab/htdocs/www/lib/smarty/templates_cchmod 777 /var/www/newznab/htdocs/www/covers/movieschmod 777 /var/www/newznab/htdocs/www/covers/animechmod 777 /var/www/newznab/htdocs/www/covers/musicchmod 777 /var/www/newznab/htdocs/www/covers/tvchmod 777 /var/www/newznab/htdocs/wwwchmod 777 /var/www/newznab/htdocs/www/installchmod 777 /var/www/newznab/htdocs/db/cachechmod -R 777 /var/www/newznab/htdocs/nzbfiles/

Replace the default apache conf to point to newznab directory:

pico /etc/apache2/sites-available/000-default.conf

Remove everything from the file and replace with:

<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>

Note

A more practical alternative to this is to create a vhost specifically for the newznab installation.

Update a few defaults in the php.ini files:

pico /etc/php/8.1/fpm/php.ini

Find and edit the following settings:

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

Enable apache mod_rewrite, fpm and restart services:

a2enmod proxy_fcgi setenvifa2enconf php8.1-fpma2enmod rewritesystemctl restart php8.1-fpmsystemctl restart apache2systemctl restart mysql

Step 6: Install newznab

Open a browser pointing to the IP address of the server and follow the instructions. Use the newznab mysql user created earlier to connect to the database. Follow the installation wizard to the end.

After completing the installation open the svn update script, uncomment the commented out lines and re-run it. This will remove any installation files and be the mechanism you use to keen newznab updated to the latest version:

pico /var/www/newznab/svn.sh<uncomment commented out lines prefixed with #>

Save, close and run the file:

/var/www/newznab/svn.sh

Step 7: Configure newznab

Open a browser, go to the admin home page http://<your server IP>/admin/site-edit.php and set up some paths and config options:

default home page : /browsenewznabID : <provided in signup email>unrar path : /usr/bin/unrarmediainfo path : /usr/bin/mediainfoffmpeg path : /usr/bin/ffmpeglame path : /usr/bin/lamesave audio preview : yescheck for password : deepdelete passworded releases : yes

Activate one group to use as a test such as alt.binaries.teevee http://<your server IP>/admin/group-list.php:

Filter for the group and press goClick the Activate link

Step 8: Run update scripts

A couple of scripts are used to populate newznab - update_binaries and update_releases. Now newznab is installed and configured it needs to be populated:

cd /var/www/newznab/htdocs/misc/update_scriptsphp update_binaries.phpphp update_releases.php

Complete

newznab is now installed. Navigate to the home page to observe indexed content

Optional Step 1: Configure newznab to run continually unattended inside screen

Take a copy of the run script so it can be edited locally without having your local changes overwritten later:

cd /var/www/newznab/htdocs/misc/update_scripts/nix_scriptscp newznab_screen.sh newznab_local.shpico newznab_local.sh

Ensure the following variables are set appropriately. Use of the threaded run script is significantly faster:

export NEWZNAB_PATH="/var/www/newznab/htdocs/misc/update_scripts"export NEWZNAB_SLEEP_TIME="30" # in seconds/usr/bin/php ${NEWZNAB_PATH}/update_binaries_threaded.php

Make the script executable:

chmod +x /var/www/newznab/htdocs/misc/update_scripts/nix_scripts/newznab_local.sh

The run script is best ran in a screen, so you can reattach later and monitor it. Screen launches a new bash shell that you can later reattach to. Name the screen so you know which one to re-attach to:

screen -S newznabcd /var/www/newznab/htdocs/misc/update_scripts/nix_scripts./newznab_local.shctrl-a d

Optional Step 2: Configure newznab to use elasticsearch

Open a browse to the admin site-edit page http://<your server IP>/admin/site-edit.php Set the following values:

use elasticsearch : yes

Open a shell and enter the following:

sudo -sapt install apt-transport-httpswget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpgecho "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.listapt-get updateapt-get install elasticsearch -ysystemctl enable --now elasticsearch.service

The default elastic installation now comes with HTTPS and authentication enabled. Disable this by entering the following:

nano /etc/elasticsearch/elasticsearch.ymlchange xpack.security.enabled: falsechange xpack.security.http.ssl: enabled: false

Restart elastic and confirm that you can connect to it locally:

systemctl restart elasticsearchcurl -X GET "localhost:9200/"

Browsing to http://<your server IP>/admin/ and dismissing the welcome message should show:

Connected to elasticsearch version 8.x.x

You now need to populate the index with initial data. Each iteration of update_releases, new data will be added to the index automatically. Every 24 hours its a good idea to totally rebuild the index manually:

cd /var/www/newznab/htdocs/misc/elastic/php eindex.php index

Navigating to http://<your server IP>/browse will now show data from elasticsearch. To optionally entirely rebuild the index every 24 hours open your newznab_local.sh created in Optional Step 1, and inside the section ‘if [ “$DIFF” -gt 43200 ] || [ “$DIFF” -lt 1 ]’ add a line to rebuild:

pico /var/www/newznab/htdocs/misc/update_scripts/nix_scripts/newznab_local.shif [ "$DIFF" -gt 43200 ] || [ "$DIFF" -lt 1 ]then ... ... /usr/bin/php ${NEWZNAB_PATH}/../elastic/eindex.php index
Newznab on Ubuntu 22.04 — Newznab 0.2.3-dev documentation (2024)

References

Top Articles
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 5401

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.