Install an Usenet Indexer -- nZEDb on CentOS 7

Have you ever wanted to run your own Usenet Indexer? Well here's a guide for you. nZEDb is a fork of nnplus, and is one of the best indexer choices there is. It's written primiarly in PHP, and installs with a basic web server config (with a few extras needed).

As a foreword, please know that I wrote this guide with the intent of running a small usenet indexer for personal use. Additional tweaking and hardware considerations will be required if you are looking to setup a publicly available indexer. The below configuration should work fine in a VM with 4 vCPU, 4GB RAM, and 40GB HDD for multiple groups, backfilled to ~120 days, and with 10 or so users. At least, that's been my experience.

Also, I run my setup with SELinux disabled (sed -i /etc/selinux/config -r -e 's/^SELINUX=.*/SELINUX=disabled/g' && systemctl reboot). An optional firewalld config is below as well, you can disable firewalld at your own discretion (systemctl disable firewalld.service && systemctl stop firewalld.service). SSL can also be configured with nZEDb, but I prefer to run mine as HTTP and put it behind my Nginx Reverse Proxy.

Let's Get Started!

1.) repos and updates:
yum -y install epel-release   # Install EPEL repo.
yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm   # Install Remi repo.
yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm   # Install Nux-Dextop repo.
yum -y update && systemctl reboot   # Update and reboot.
2.) prerequisites:
yum -y install ffmpeg git mariadb mariadb-server mediainfo nginx p7zip php56 php56-php-cli \
php56-php-fpm php56-php-gd php56-php-imagick php56-php-mbstring php56-php-mcrypt php56-php-mysqlnd php56-php-opcache php56-php-pear time tmux unrar
systemctl start nginx.service && systemctl start php56-php-fpm.service && systemctl start mariadb.service   # Start services
cd /tmp && curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
3.) php config:
vi /opt/remi/php56/root/etc/php.ini
---
date.timezone = America/New_York   # Set to your timezone - http://php.net/manual/en/timezones.php
max_execution_time = 120
memory_limit = -1
---

vi /opt/remi/php56/root/etc/php-fpm.d/www.conf
---
listen = /var/run/php56-php-fpm.sock
listen.owner = nginx ; SOCKS permission
listen.group = nginx ; SOCKS permission
listen.mode = 0660 ; SOCKS permission
user = nginx ; PHP-FPM running user
group = nginx ; PHP-FPM running group
php_value[session.save_path] = /var/www/sessions
---
mkdir -p /var/www/sessions   # Directory for socket file and php sessions.
ln -s /opt/remi/php56/root/usr/bin/php /usr/bin/php
4.) mariadb config:
vi /etc/my.cnf
---
[mysqld]
# nzedb recommended
max_allowed_packet      = 12582912
group_concat_max_len    = 8192
---
systemctl restart mariadb.service   # Restart mariadb service
mysql_secure_installation   # Set root password and other settings

## Create database
---
mysql -u root -p # Enter root password
CREATE DATABASE IF NOT EXISTS nzedbdb;
GRANT ALL PRIVILEGES ON nzedbdb.* TO 'nzedbuser'@'localhost' IDENTIFIED BY 'nzedbpass' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit
---
5.) nginx config:
rm -rf /etc/nginx/nginx.conf
vi /etc/nginx/nginx.conf
---
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log;

pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;

    keepalive_timeout  65;

    include /etc/nginx/conf.d/*.conf;

    index   index.html index.htm;
}
---

vi /etc/nginx/conf.d/nzedb.conf
---
server {
  listen 80;
  server_name localhost;
  root /var/www/nZEDb/www/;
  index index.php index.html;

  access_log /var/log/nginx/nzedb_access.log;
  error_log /var/log/nginx/nzedb_error.log;

  location / {
   try_files $uri $uri/ @rewrites;
   }

  # This is where the nZEDb covers folder should be in.
  location ^~ /covers/ {
      root /var/www/nZEDb/resources;
  }

  location @rewrites {
    rewrite ^/([^/\.]+)/([^/]+)/([^/]+)/? /index.php?page=$1&id=$2&subpage=$3 last;
    rewrite ^/([^/\.]+)/([^/]+)/?$ /index.php?page=$1&id=$2 last;
    rewrite ^/([^/\.]+)/?$ /index.php?page=$1 last;
  }

  location /admin {
  }

  location /install {
  }

  location ~ \.php$ {
      include fastcgi_params;
      fastcgi_pass unix:/var/run/php56-php-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
   }

   location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
    deny all;
  }
}
---
6.) install nZEDb:
cd /var/www/ && git clone https://github.com/nZEDb/nZEDb.git   # Download zNEDb.
chown -R nginx:nginx /var/www/{nZEDb,sessions}   # Set file ownership.
cd /var/www/nZEDb
composer install
systemctl enable nginx.service && systemctl enable php56-php-fpm.service && systemctl enable mariadb.service   # Start services on boot.
systemctl reboot   # Restart server.
7.) Firewall Considerations:

You will either need to disable firewalld by doing:

systemctl disable firewalld.service && systemctl stop firewalld.service

Or configure firewalld to allow HTTP traffic.

firewall-cmd --set-default-zone=home  # You can use one of the other zones, if you like.  I prefer using home instead of the default "public", just adjust accordingly below.
firewall-cmd --permanent --zone=home --add-service=http   # Add HTTP service to firewalld to allow HTTP/80 traffic
systemctl reboot

nZEDb is now installed and ready to be configured. Browse to http://hostname/install and follow through the install process. Once you complete the step-by-step install, in the Admin Hangout, browse to Site Settings > Groups > View, and pick a group to activate (I recommend starting with a.b.teevee). Next lets go to the Tmux Settings (Admin Hangout > Site Settings > Tmux Settings) and set a few settings.

Tmux Scripts Running > yes
Run Sequential > Basic Sequential
Update Binaries > Simple Threaded Update
Backfill > All
Update Releases > Update Releases
Postprocess Additional > All
Postprocess Non-Amazon > Properly Renamed Release
Decrypt Hash Based Release Names > All
Update TV and Theater Schedules > yes

Finally, lets go back to the terminal and start up the tmux scripts to update binaries and releases.

cd /var/www/nZEDb/misc/update/nix/tmux/
php start.php

Several update scripts are now running through tmux. To detach from tmux but leave those scripts running, just press control+a d and you are back to your terminal. This way, even once you log off the server, that tmux session is still running so the update scripts are running in the background. To re-attach to that session, first try tmux ls to see what current tmux sessions are running, then try tmux attach -t nZEDb to re-attach to a session with the name nZEDb (the default session name for nZEDb's tmux scripts).

That's it! You now have your own Usenet Indexer running, and pulling in releases. Obviously there is a lot more configuration to go, and I recommend checking out nZEDb's documentation for that. Go add more groups, change the theme, configure stuff, and have fun!

Leave me a comment and let me know what you think!


Related Posts


Share on: Twitter | Facebook | Google+ | Email


comments powered by Disqus