Ever wanted to run your own usenet search engine? This howto will go through the steps required to install the Newznab usenet indexer on Ubuntu. Ubuntu 12.04 was used for this guide, however all current versions of Ubuntu should be the same.
Installing and setting up MySQL
$ sudo apt-get install mysql-server mysql-client
Run the MySQL client:
$ mysql -u root -p
You will be asked for MySQL root password. If you don’t have a password set for the root account, simply press enter when prompted.
Create a new mysql user:
CREATE USER 'newznab'@'localhost' IDENTIFIED BY 'somepassword';
Create a new blank database for newznab to use:
CREATE DATABASE newznab;
Assign permissions for the newly created mysql user:
GRANT ALL ON newznab.* TO 'newznab'@'localhost';
Flush the privileges to make sure the newly added users and permissions are ready to use:
FLUSH PRIVILEGES;
Exit the MySQL client:
exit
Installing Apache and PHP
$ sudo apt-get install apache2 php5 php5-dev php-pear php5-gd php5-mysql php5-curl
Downloading and Installing Newznab
Download Newznab
$ wget http://www.newznab.com/newznab-0.2.3.zip
Check for the latest release from http://www.newznab.com/.
Install the unzip package if it’s not already installed
$ sudo apt-get install unzip
Unzip Newznab
$ unzip newznab-0.2.3.zip
Move the extracted Newznab files to the apache www folder.
$ sudo mv newznab-0.2.3 /var/www/newznab
Change the permissions of the Newznab website folder to Apache has full access.
$ sudo chown -R www-data:www-data /var/www/newznab $ sudo chmod 777 -R /var/www/newznab/nzbfiles $ sudo chmod 777 -R /var/www/newznab/www/covers
Create the Apache site file for Newznab
$ sudo nano /etc/apache2/sites-available/newznab
Paste in the following:
Listen *:8082 <VirtualHost *:8082> <Directory /var/www/newznab/www/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/newznab/www LogLevel warn ServerSignature Off </VirtualHost>
Change the port number and any other settings to suit your requirements.
Enable the newznab site in the Apache config.
$ sudo a2ensite newznab
Enable the Apache rewrite module
$ sudo a2enmod rewrite
Modify the Apache PHP settings
$ sudo nano /etc/php5/apache2/php.ini
Make the following changes:
find | change it to |
max_execution_time = 30 | max_execution_time = 90 |
memory_limit = 128M | memory_limit = 256M |
;date.timezone = | date.timezone = <your timezone here> |
Replace <your timezone here> with your the correct timezone for your location. Use the correct timezone format as per http://php.net/manual/en/timezones.php
Save the file and exit the editor.
Also make these same changes (except the memory_limit setting) to the command line version of PHP:
$ sudo nano /etc/php5/cli/php.ini
find | change it to |
max_execution_time = 30 | max_execution_time = 90 |
;date.timezone = | date.timezone = <your timezone here> |
Save the file and exit the editor.
Restart Apache:
$ sudo service apache2 reload
You should now be able to browse to the Newznab site, which will load the initial configuration / installation options for Newznab.
Initial Configuration of Newznab
Using the above example, Apache/Newznab will be listening on port 8082, so make sure you browse to
http://ip_address:8082
Replace ip_address with the IP or hostname of your Newznab server.
Once you load the webpage, it should go through a number of initial configuration steps.
Step 1:
Make sure the “pre flight check” runs through OK without any “Errors”.
Step 2:
Set up the database connection.
Enter the MySQL username and password that you set up in the MySQL configuration section.
Step 3:
Set up the news server configuration. Enter your server address, username, and password for your usenet provider.
Step 4:
Save the settings.
Step 5:
Set up the admin user.
Enter a username, password, and email address to use.
Step 6:
Set a NZB file path. This should default to the correct location.
Post Installation of Newznab
The installation is now complete and you are ready to use Newznab.
Feel free to remove the installation files after everything is working fine:
$ sudo rm -rf /var/www/newznab/www/install
You can now log into Newznab (using the username and password created in Step 5 above) and customize the site and indexing options.
Note: Setting up the indexing options is beyond the scope of this howto article.
Thanks very much for the guide.
I’m wondering if you could help me with a further question regarding setting up newznab (well MySQL in particular).
I would like to move the mysql database to a different drive on my system as I know that it will get quite large after retrieving and processing headers.
I have tried following a few guides but I seem to run into permissions errors when trying to restart mysql?
Would you be able to give a quick step by step in taking the setup from your how-to above, and moving the mysql datadir to another drive on the same machine?
Cheers
No worries. I’ll look into writing a howto on moving the MySQL databases, but in the meantime, I would recommend you disable the MySQL AppArmor profile in case that’s whats causing the issues. AppArmor is installed by default with Ubuntu, so there’s a good chance that’s where the issue is, as it wont know where your new MySQL data folder is, and will block access to it.
To disable the MySQL profile in AppArmor:
Probably a good idea to restart MySQL after disabling the MySQL AppArmor profile, however I’m not sure if its actually required.
Re-enable the AppArmor profile:
See how you go with the above.