Newznab on Ubuntu 16.04 ============================= This guide will help you install everything you need to get Newznab+ running on a fresh Ubuntu 16.04 server. At the end are optional sections for installing sphinx search and to configure scripts to allow newznab to continually run. Step 1: Install required packages ------------------------------ Enter the following:: sudo -s apt update && apt upgrade apt install ssh screen apache2 php mariadb-server libapache2-mod-php -y apt install php-pear php-gd php-mysql php-memcache php-curl php-json php-mbstring unrar lame mediainfo subversion ffmpeg 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 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=8192 innodb_flush_log_at_trx_commit = 2 Step 3: Create web directories --------------------- Enter the following:: mkdir /var/www/newznab mkdir /var/www/newznab/htdocs mkdir /var/www/newznab/logs Step 4: Create a script for keeping newznab up to date --------------------- Enter the following:: pico /var/www/newznab/svn.sh 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_scripts php update_database_version.php cd /var/www/newznab/htdocs service memcached restart service apache2 restart 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_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/ 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:: Options FollowSymLinks AllowOverride All Order allow,deny allow from all DocumentRoot /var/www/newznab/htdocs/www ErrorLog /var/www/newznab/logs/error.log CustomLog /var/www/newznab/logs/access.log combined .. 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/7.0/apache2/php.ini Find and edit the following settings:: date.timezone = 'Europe/London' max_execution_time = 120 memory_limit = -1 Enable apache mod_rewrite and restart services:: a2enmod rewrite service apache2 restart service mysql restart 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 update newznab to the latest version:: pico /var/www/newznab/svn.sh 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:///admin/site-edit.php and set up some paths and config options:: default home page : /browse newznabID : 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 to use as a test such as alt.binaries.teevee http:///admin/group-list.php:: Filter for the group and press go Click 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_scripts php update_binaries.php php 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_scripts cp newznab_screen.sh newznab_local.sh pico 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 newznab cd /var/www/newznab/htdocs/misc/update_scripts/nix_scripts ./newznab_local.sh ctrl-a d Optional Step 2: Configure newznab to use sphinxsearch --------------------- Open a browse to the admin site-edit page http:///admin/site-edit.php Set the following values:: use sphinx : yes index releasefiles : yes index predb : yes Open a shell and enter the following:: sudo -s apt install sphinxsearch -y cd /var/www/newznab/htdocs/misc/sphinx php nnindexer.php generate php nnindexer.php index full all php nnindexer.php index delta all php nnindexer.php daemon Once the indexes have been built running update_releases will populate them:: cd /var/www/newznab/htdocs/misc/update_scripts php update_releases.php