Skip to content

Ubuntu Install guide

DariusIII edited this page Dec 17, 2018 · 103 revisions

Ubuntu Web Guide.

This guide was designed for Ubuntu 16.04+ and derivatives (Linux Mint/Elemantary OS/etc.), using this guide on Debian or other Linux Distributions might or might not function. This guide might have errors or be obsolete by the time you read it, doing some research on your part on how to fix issues if they arise dkpg-iis required.

Notes:

In this guide you will see commands within grey rectangles, example: this is an example When you see these, you must type them into a command line interface (terminal window).

PHP 7.2 and MariaDB 10.2 are the minimum supported versions.


Step 1 Updating your operating system:

Update all your sources:

sudo apt-get update


Upgrade your applications:

sudo apt-get upgrade


Optional: Upgrade some other stuff (like the kernel).

sudo apt-get dist-upgrade

You must now reboot your server.

sudo reboot


Step 2 Installing pre-requisite software:


These programs will be used later on to install additional software. They might already be installed on your operating system.

sudo apt-get install software-properties-common python-software-properties git make


Step 3 Adding a repository for the minimum supported PHP version:


NNtmux supports PHP version 7.2 or higher, if your distro does not have 7.2+, you must add a repository.

To add PHP 7.2 which is the current supported versions of PHP:

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update


Step 4 Installing PHP and the required extensions:


Note that some extensions might be missing here,

sudo apt-get install php-pear php7.2 php7.2-cli php7.2-dev php7.2-common php7.2-curl php7.2-json php7.2-gd php7.2-mysql php7.2-mbstring php7.2-xml php7.2-bcmath php-imagick

Do not install mcrypt as php7.2 has dropped support for that extension


Step 5 Installing a MySQL server and client:


You have multiple choices when it comes to a MySQL server and client, you will need to do some research to figure out which is the best for you. We recommend MariaDB for most people.

To find out what the correct repository is for your version of Ubuntu visit: https://downloads.mariadb.org/mariadb/repositories

The repository below is for Ubuntu 16.04 with MariaDB 10.2

MariaDB (we recommend this):

sudo apt-get install software-properties-common

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://www.ftp.saix.net/DB/mariadb/repo/10.2/ubuntu xenial main'

sudo apt update

sudo apt-get upgrade

sudo apt-get install mariadb-server mariadb-client libmysqlclient-dev


Step 6 Configuring MySQL:


Edit my.cnf (the location can vary, type mysqld -v --help | grep -A 1 'Default options' to find all the possible locations):

sudo nano /etc/mysql/my.cnf

Add (or change them if they already exist ; they go under the [mysqld] section) the following:

max_allowed_packet = 16M

group_concat_max_len = 8192

max_connections = 200

Add (or change them if they already exist ; they go under the [innodb] section) the following:

innodb_file_format = BARRACUDA

innodb_large_prefix = 1

innodb_file_per_table = 1

innodb_buffer_pool_size = 256M

If you are using MariaDB 10.3, ommit innodb_file_format = BARRACUDA and innodb_large_prefix = 1 from my.cnf as they are deprecated in 10.3 version.

Consider raising the key_buffer_size to 256M to start, later on you can raise this more as your database grows.

You must convert your database to InnoDB.

You will be required to change the innodb_buffer_pool_size as your database grows a good starting point is 256M. You can run php show_table_sizes.php 0 from /var/www/NNTmux/misc/testing/DB to see the recommended innodb_buffer_pool_size.

sudo service mysql restart


[Mandatory] Create a MySQL user.

Never use the root user for your scripts.

Log in to MySQL with the root user

sudo mysql -u root -p

nntmux is the databasename, you can change this if you want.

CREATE DATABASE nntmux;

Change YourMySQLServerHostName to the hostname of the server.
If your MySQL server is local, use localhost. If remote, try the domain name or IP address. It has been reported 127.0.0.1 does not work for the hostname.
Change YourMySQLUsername for the username you will use to connect to MySQL in NNTmux.
Do not remove the quotes on the name / hostname / password.

GRANT ALL ON nntmux.* TO 'YourMySQLUsername'@'YourMySQLServerHostName' IDENTIFIED BY 'SomePassword';

GRANT ALL PRIVILEGES ON *.* TO 'YourMySQLUsername'@'YourMySQLServerHostName' WITH GRANT OPTION;

flush privileges;

Exit MySQL:

quit;


Step 7 Installing and configuring a web server:


You have many options. We will however show you 2 options, Apache2 or Nginx. Only install Apache2 or Nginx, do not install both to avoid issues.

Apache:

sudo apt-get install apache2

You also need to install the following package:

sudo apt-get install libapache2-mod-php7.2

apache2 -v


Apache 2.4:

Create a site configuration file:

sudo nano /etc/apache2/sites-available/NNTmux.conf

Paste the following into it (changing your paths as required):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName localhost
    DocumentRoot "/var/www/NNTmux/public"
    LogLevel warn
    ServerSignature Off
    ErrorLog /var/log/apache2/error.log
    <Directory "/var/www/NNTmux/public">
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    Alias /covers /var/www/NNTmux/resources/covers
</VirtualHost>

Save and exit nano.

Edit apache to allow overrides in the /var/www folder (or the folder you will put NNTmux into):

sudo nano /etc/apache2/apache2.conf

Under <Directory /var/www/>, change AllowOverride None to AllowOverride All

Save and exit nano.

Disable the default site, enable NNTmux, enable rewrite, restart apache:

sudo a2dissite 000-default

sudo a2ensite NNTmux.conf

sudo a2enmod rewrite

sudo service apache2 restart


Nginx:

(Optional) You might want to remove apache2 first:

sudo apt-get remove apache2

Install Nginx:

sudo apt-get install -y nginx

[Optional - Start]
If you wish to install the newest stable version of Nginx, follow these steps.

You can check if your current version is outdated compared to the Nginx downloads page by typing this command:

nginx -v

Add the Nginx PPA:

sudo add-apt-repository ppa:nginx/stable

Update your sources:

sudo apt-get update

Install the latest version of Nginx:

sudo apt-get install -y nginx

[Optional - End]

Install php fpm, which sends the PHP files to Nginx:

sudo apt-get install -y php7.2-fpm

Create a nginx configuration file for your NNTmux website:

sudo nano /etc/nginx/sites-available/NNTmux

Paste the following into the file, change the settings as needed: The server_name must be changed if you want to use a different hostname than localhost. Example: "server_name localhost 192.168.1.29 mydomain.com;" would work on all those 3. The fastcgi_pass can be changed to TCP by uncommenting it, sockets are faster however.

server {
    # Change these settings to match your machine.
    listen 80 default_server;
    server_name localhost;

    # These are the log locations, you should not have to change these.
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # This is the root web folder for NNTmux, you shouldn't have to change this.
    root /var/www/NNTmux/public/;
    index index.html index.htm index.php;

    # Everything below this should not be changed unless noted.
    location ~* \.(?:css|eot|gif|gz|ico|inc|jpe?g|js|ogg|oga|ogv|mp4|m4a|mp3|png|svg|ttf|txt|woff|xml)$ {
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

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

    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;

        # Uncomment the following line and comment the .sock line if you want to use TCP.
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/var/run/php7.2-fpm.sock;

        # The next two lines should go in your fastcgi_params
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Save and exit nano.

If you have changed the fastcgi_pass to tcp (127.0.0.1:9000), you must edit www.conf to listen on it instead of sockets:

sudo nano /etc/php/version.number/fpm/pool.d/www.conf Change listen = /var/run/php7.2-fpm.sock to listen = 127.0.0.1:9000 Save and exit nano.

Create a log folder if it does not exist:

sudo mkdir -p /var/log/nginx

sudo chmod 755 /var/log/nginx

Delete the default Nginx site:

sudo unlink /etc/nginx/sites-enabled/default

Make NNTmux the default Nginx site:

sudo ln -s /etc/nginx/sites-available/NNTmux /etc/nginx/sites-enabled/NNTmux

Restart Nginx and php7.2-fpm:

sudo service nginx restart

sudo service php7.2-fpm restart or sudo /etc/init.d/php7.2-fpm restart


Step 7.1 Add your user to the www-data group

Regardless of which web server you use, you should add your user to the www-data group so that you may create/edit files belonging to the group. Replace $USER for your username, if you will not use the current user for nntmux.

sudo usermod -a -G www-data $USER

This requires you to log back in before it takes effect. Do so now or before the Aquiring NNTmux step.

sudo reboot


Step 8 Configuring PHP:


Open php.ini for the CLI SAPI (/etc/php/7.2/cli/php.ini):

sudo nano /etc/php/7.2/cli/php.ini

Change the following settings:

max_execution_time = 120

The following can be set to -1 if you have a large amount of system RAM (>=8GB):

memory_limit = 1024M

Change your timezone from a list of timezones here. Remove the preceding ;

date.timezone = YourLocalTimezone

Enable error logging (Needed when reporting bugs)

error_reporting = E_ALL

log_errors = On

error_log = php-errors.log

Close and save this file.

Open the Web SAPI php.ini (for PHP7 /etc/php/7.2/).

If you have installed Apache2: sudo nano /etc/php/7.2/apache2/php.ini

If you have installed Nginx: sudo nano /etc/php/7.2/fpm/php.ini

Change the settings using the same settings as the CLI SAPI.

Restart Apache2 or PHP-FPM (if you use nginx for example):

sudo service apache2 restart

sudo service php7.2-fpm restart


Step 9 Installing extra software:


Unrar:

You can install Unrar from the repositories, but it's quite old:

sudo apt-get install unrar

You can also install it by downloading the newest version (recommended, as some RAR files require version 5+): Go to http://www.rarlab.com/download.htm, look for the newest unrar version (5.5.0 when this guide was updated), right click it and copy the link. Replace the link below with the one you copied:

mkdir -p ~/new_unrar && cd ~/new_unrar

wget http://www.rarlab.com/rar/rarlinux-x64-5.2.1.tar.gz

tar -xzf rarlinux*.tar.gz

sudo mv /usr/bin/unrar /usr/bin/unrar4

sudo mv rar/unrar /usr/bin/unrar

sudo chmod 755 /usr/bin/unrar

cd ~/ && rm -rf ~/new_unrar


On Ubuntu 16.04 you can use the following command to install all additional requirements or follow the individual installations steps below:

sudo apt-get install p7zip-full mediainfo lame ffmpeg libav-tools


7zip:

sudo apt-get install p7zip-full


Mediainfo:

Go to http://mediaarea.net/en/MediaInfo/Download/Ubuntu, download the deb files for libmediainfo, libzen0 and mediainfo (CLI)

You can download by right clicking on them, copy link, then type wget and paste the link after.

Once you have all 3 deb files, install them by typing sudo dpkg -i followed by the name of the file. You may have to install libzen0 package first. If so do:

sudo apt-get install libzen0


Lame:

sudo apt-get install lame


FFmpeg or avconv:

You can alternatively install ffmpeg:

(manual compilation) https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu


Step 10 Acquiring NNTmux:


Switch your active group to 'www-data'.

newgrp www-data

Switch to the system's www location.

cd /var/www/

This folder should have been created when apache2 was installed (by php7.2 dependencies). If, for whatever reason, it did not do:

mkdir -p /var/www

sudo chown www-data:www-data /var/www

sudo chmod 775 /var/www


Install Composer and git clone NNTmux


Step 11 Setting up NNTmux:


Now you need to copy the sample .env config file and change the settings for you NNTmux environment:

cp .env.example .env

nano .env

As a minimum update the following settings:


DB_HOST=yourMySQLServer

DB_PORT=3306

DB_USER=nntmuxMySQLuser

DB_PASSWORD=nntmuxMySQLpassword

DB_NAME=nntmux

NNTP_USERNAME=YourNNTPUsername

NNTP_PASSWORD=YourNNTPPassword

NNTP_SERVER=YourNNTPServerAddress

NNTP_PORT=119

NNTP_SSLENABLED=false

NNTP_SOCKET_TIMEOUT=120

ADMIN_USER=AdminUserNick

ADMIN_PASS=AdminUserPass

ADMIN_EMAIL=AdminUserEmailAddress

APP_ENV=production

APP_DEBUG=false

APP_TZ=YourTimeZone (Same as your PHP TimeZone)

APP_DOMAIN=

SESSION_DOMAIN=

If command hostname -f reports empty hostname use above settings, if they report correct domain, you can use that for APP and SESSION domains.

You should only use APP_ENV=local when you are setting your server up in a testing environment else you need to set APP_ENV=production. Fail to set it to production and disabling debug will expose sensitive information to the internet.


For faster installs with composer, we suggest installing hirak/prestissimo, which can speed up installing of required components from minutes to seconds:

composer global require hirak/prestissimo

Install NNTmux additional components by issuing the following command:

composer install

Set the required directory permissions:

Folders must be owned by www-data group (sudo chown -R youruser:www-data + foldername)

sudo chown -R your_user:www-data /var/www/NNTmux/bootstrap/cache/

sudo chown -R your_user:www-data /var/www/NNTmux/storage/logs/

sudo chown -R your_user:www-data /var/www/NNTmux/resources/tmp/

sudo chown -R your_user:www-data /var/www/NNTmux/public/

sudo chmod -R 755 /var/www/NNTmux/vendor/

sudo chmod -R 777 /var/www/NNTmux/storage/

sudo chmod -R 777 /var/www/NNTmux/resources/

sudo chmod -R 777 /var/www/NNTmux/public/

Configure nntmux by issuing the following commands:

php artisan nntmux:install

You will be prompted with several questions to be sure that everything goes smoothly

Open your web browser and point it to your site.

If this only shows you the web servers default page, you probably need to use a domain name of some kind. Open your local hosts file (on the computer which you are trying to browse from) and add an entry for the target server.

sudo nano /etc/hosts

IpAddressOfYourServer <server_name_used_in_configuration>

Next, head to the edit site section, turn on header compression if your server supports it, put in paths to optional software, like unrar/ffmpeg/etc..

To figure out the path to the optional software, type which followed by the name of the program. Example: which unrar

Signing up to all the API services(Amazon/Trakt/OMDB/etc) is recommended, the keys we offer are used by many NNTmux sites and are throttled so you will get almost no results from those.


[Mandatory] SPHINX Search:


sudo add-apt-repository ppa:builds/sphinxsearch-rel22

sudo apt-get update

sudo apt-get install sphinxsearch

sudo service sphinxsearch stop

sudo mv /etc/sphinxsearch/sphinx.conf /etc/sphinxsearch/sphinx.conf.1

sudo cp /var/www/NNTmux/misc/sphinxsearch/sphinx.conf /etc/sphinxsearch/sphinx.conf

sudo mkdir -p /var/lib/sphinxsearch/data/

sudo mkdir -p /var/log/sphinxsearch/

sudo service sphinxsearch start

mysql -u root -p

show engines;

If there is no mention of sphinx, you need to perform a one time install of the plugin by simply typing:

INSTALL SONAME 'ha_sphinx';

quit;

cd /var/www/NNTmux/misc/sphinxsearch/

php create_se_tables.php 0 9312

php populate_rt_indexes.php releases_rt


Step 12 Indexing:


Manual indexing:

We do not recommend doing manual indexing, as NNTmux is heavily using tmux for its scripts. Automatic indexing is what we recommend.


Automatic indexing:

Indexing using the Tmux scripts(this is the only option now, screen scripts have been removed):

Install tmux, tmux is similar to screen but allows to have multiple terminals visible and other features.

sudo apt-get purge tmux

Run the included tmux install script, it will fetch, compile and install latest tmux from their official github page

./install_tmux.sh

On your website, head to the admin tmux page (http://IpAddressOfYourServer/admin/tmux-edit)

Take your time and read through all the options carefully.

Click on Save Tmux Settings at the bottom of the page.

From your installation root

Start the tmux script.

php artisan tmux-ui:start

To stop tmux and optionaly kill the session(true to kill the tmux session, false to just stop tmux scripts)

php artisan tmux-ui:stop true

You can now detach from tmux using this keyboard combo(press control and a, let go press d): control+a d

To re-attach to tmux, type tmux attach or tmux att


There are other automated scripts, you can open them in a text editor or ask around / do research to see what they do.


Step 13 Extra stuff:


IRCScraper:

IRCSraper is a bot that connects to a IRC server to download PreDB information into your NNTmux SQL database.

This helps renaming releases and gives extra information on your releases.

You need to edit your .env file for irc settings change, or defaults from config/irc_settings.php will be used

Update at least IRC_USERNAME with a nickname to be used on the IRC channel

Make sure you set "Scrape Irc Channels" to yes within the TMUX Admin settings


Comment sharing:

It is possible to share comments between NNTmux and newznab sites.


Redis server stats:

You can enable stats monitoring of redis server (if you use it). You need to do the following:

sudo apt-get install redis-server php-redis

sudo apt-get install rubygems ruby-dev

sudo gem install redis-stat

sudo nano /etc/redis/redis.conf

maxmemory 128mb

maxmemory-policy allkeys-lru

sudo systemctl restart redis-server.service

sudo systemctl enable redis-server.service

Redis is recommended caching server


Queues

Email queues

Conclusion

For questions join IRC, server Synirc channel #tmux

Clone this wiki locally