Skip to content

Install Guide: Fedora

kaibosh edited this page Mar 8, 2018 · 140 revisions

A rather long install guide for Fedora and similar distros. This document was prepared using Fedora 24/25 with Apache & MariaDB and SElinux disabled.

NOTE: Sections noted as "Optional" can be skipped for first time installations!

The installation example is started using the root user, and later uses a specific nzedb user.

Package Installation

Install development packages (useful for compiling stuff later on)

dnf groupinstall "Development Tools" "Development Libraries"

Install general packages needed by nZEDb.

dnf install yasm lame php-devel php php-pear php-gd php-mysqlnd php-curl git p7zip php-mbstring php-mcrypt php-pecl-imagick # php-pear-MDB2-Driver-mysql (old?)

Optionally:

dnf install php-memcached php-opcache perl-Text-Template libevent-devel ncurses-devel

Note: perl-Text-Template is for mysqltuner, libevent and ncurses-devel for compiling tmux.

Configure PHP

  • vi /etc/php.ini
memory_limit = 1024M   # (1G minimum, 2G if system has RAM)
post_max_size = 64M    # (used when doing large import/exports)
date.timezone = "Europe/YourCountry"
max_execution_time = 200    # (>=120 is recommended)

Note: the timezone settings of system, php, and mariadb must match.

Optional If you installed php-opcache, you have the option to enable opcache for php cli scripts. Read these tuning considerations:

http://stackoverflow.com/questions/25044817/zend-opcache-opcache-enable-cli-1-or-0-what-does-it-do

https://github.com/zendtech/ZendOptimizerPlus

  • vi /etc/php.d/10-opcache.ini
opcache.enable_cli=1

MariaDB

Initial configuration below to get you started. Use MySQLtuner.pl to tune the database once running.

  • vi /etc/my.cnf.d/mariadb-server.cnf

Under [server]

group_concat_max_len=8192 # May need set higher if ITEMS_PER_PAGE is above default in settings.php
innodb_file_per_table     # Important that this is present (or =1) before nzedb DB is created
max_allowed_packet=128M   # (For dumping large tables)
systemctl restart mariadb
systemctl enable mariadb

Optional : If more than 300 groups are to be activated, increase the open file limit.

vi /etc/my.cnf.d/mariadb-server.cnf

Under [server]

open_files_limit=24576

Increase the total system limit and call "sysctl -p" after this edit:

vi /etc/sysctl.conf
fs.file-max = 256000

Also increase the open files limit for all users:

vi /etc/security/limits.conf
* soft nofile 24576
* hard nofile 32384

The systemd start scripts should also be adjusted

mkdir /etc/systemd/system/mariadb.service.d/
vi /etc/systemd/system/mariadb.service.d/limits.conf
[Service]
LimitNOFILE=24576

systemctl daemon-reload
systemctl restart mariadb

Check the mariadb logs following the final restart. It will throw a warning message if it cannot use the configured number of open files.

Optional: Consider securing the default mariadb installation.

mysql_secure_installation   # as root

Apache

Ensure apache is listening on the IP and port you expect

  • vi /etc/httpd/conf/httpd.conf
  • Listen 10.x.x.x:80

Create nZEDb VirtualHost config

  • vi /etc/httpd/conf.d/nzedb.conf
  <VirtualHost *:80>
      Alias /nZEDb /var/www/nZEDb/www
      ServerAdmin [email protected]
      DocumentRoot /var/www/nZEDb/www
      ServerName nzedb.example.com
      ErrorLog logs/nzedb.log
      CustomLog logs/nzedb.log common
      <Directory "/var/www/nZEDb/www">
                  AllowOverride All
                  Options FollowSymLinks
                  Order Deny,Allow
                  Allow from all
                  Require all granted
      </Directory>
      Alias /covers /var/www/nZEDb/resources/covers
      <Directory "/var/www/nZEDb/resources/covers">
                  AllowOverride All
                  Options FollowSymLinks
                  Order Deny,Allow
                  Require all granted
      </Directory>
      <Files ".ht*">
        Require all denied
      </Files>
  </VirtualHost>
systemctl restart httpd
systemctl enable httpd

Open up the firewall for http & https ports. Be sure to edit the Permanent Configuration.

  • firewall-config

Configure memcached (optional)

dnf install memcached    (done above)
vi /etc/sysconfig/memcached   (configure as desired)
systemctl start memcached
systemctl enable memcached
echo stats | nc localhost 11211   (test)

Enable memcache in /var/www/nZEDb/config.php

Custom PHP extension for FAST yEnc decodes (Optional)

Note: Not compatible with php 7.x (deprecated) See below for Fedora 25+

See kevinlekiller's git page: simple_php_yenc_decode

As root:

dnf install boost-regex boost-devel swig gcc-c++

git clone & compile

git clone https://github.com/kevinlekiller/simple_php_yenc_decode.git
cd simple_php_yenc_decode/source
swig -php -c++ yenc_decode.i
g++ `php-config --includes` -fpic -c yenc_decode_wrap.cpp
g++ -fpic -c yenc_decode.cpp -lboost_regex
g++ -shared *.o -o simple_php_yenc_decode.so -lboost_regex

As root:

mkdir /usr/lib64/php/extensions
cp -p /var/www/nZEDb/simple_php_yenc_decode/source/simple_php_yenc_decode.so  /usr/lib64/php/extensions
vi /etc/php.ini    

and add..

extension=/usr/lib64/php/extensions/simple_php_yenc_decode.so

after the extension_dir lines

Niels php-yenc extension for FAST yEnc decodes (Optional)

Note: This module is compatible with php 7.x and Fedora 25+

Install prerequisite software.

dnf install gcc re2c php-devel pcre-devel

Install Zephir's external parser

git clone git://github.com/phalcon/php-zephir-parser.git
cd php-zephir-parser
sudo ./install

Add the parser extension to php.ini

[Zephir Parser]
extension=zephir_parser.so

Now install zephir

git clone https://github.com/phalcon/zephir
cd zephir
./install -c         # calls sudo
zephir help          # tests zephir install

Now retrieve, compile and install Niel's php-yenc

wget https://github.com/niel/php-yenc/archive/v1.3.0.tar.gz
tar -xzvf v*
cd php-yenc
zephir build         # calls sudo and installs into the modules dir
vi /etc/php.ini      # search for extension= 
    extension=/usr/lib64/php/modules/yenc.so     
    
php -m | grep yenc   # you should see yenc

nZEDb will automatically detect and use the php-yenc extension.

Install php-opcache stats page (optional)

Best to install this after initial nZEDb installation.

cd /var/www/nZEDb/www/admin
wget https://raw.github.com/rlerdorf/opcache-status/master/opcache.php

Post-Processing extras (optional, but strongly recommended)

unrar

Fedora 27's unrar version is recent enough.

dnf install unrar

Alternatively you can download latest tarball from rarlab http://www.rarlab.com/download.htm

wget http://www.rarlab.com/rar/rarlinux-x64-5.X.X.tar.gz
tar -xzf rarlinux-x64-5.* 
cd rar
sudo cp -p unrar /usr/local/bin/

Once nZEDB is up & running you point to this unrar version in Site -> Edit

ffmpeg

It's better to use the latest version possible. Here two options below:

Easiest option with automatic updates

dnf config-manager --add-repo=http://negativo17.org/repos/fedora-multimedia.repo
dnf install ffmpeg

Second option is to download the latest tarball from http://ffmpeg.org or the static build here: http://johnvansickle.com/ffmpeg/

wget http://ffmpeg.org/releases/ffmpeg-2.0.1.tar.bz2
bunzip2 ffmpeg-2.0.1.tar.bz2
tar -xf ffmpeg-2.0.1.tar
cd ffmpeg-2.0.1
./configure
make -j4  #   (j optional)
make install

mediainfo

The version maintained in the standard fedora repo is normally fine.

dnf install mediainfo mediainfo-gui

Alternatively, for the very latest version see https://mediaarea.net e.g.

wget https://mediaarea.net/download/binary/mediainfo/0.7.99/mediainfo-0.7.99.x86_64.Fedora_26.rpm
wget https://mediaarea.net/download/binary/mediainfo-gui/0.7.99/mediainfo-gui-0.7.99.x86_64.Fedora_26.rpm
wget https://mediaarea.net/download/binary/libmediainfo0/0.7.99/libmediainfo-0.7.99.x86_64.Fedora_26.rpm
wget https://mediaarea.net/download/binary/libzen0/0.4.37/libzen-0.4.37.x86_64.Fedora_26.rpm
rpm -ivh *.rpm

Sphinx Search (optional, recommended this be installed later)

  • yum install sphinx

Check the installed MariaDB plugins

  • MariaDB [(none)]> SHOW ENGINES;

If the Sphinx engine is not present use this once to load the dynamic module

  • MariaDB [(none)]> INSTALL SONAME 'ha_sphinx';

Refer to the separate sphinx directory (misc/sphinxsearch) for further installation steps.

Create nzedb user-id & install composer

It is strongly recommended that you run nZEDb as a non-root user.

useradd -c nzedb nzedb
dnf install composer

Certain directories need to be read/writable to both the nzedb user and apache. One way is to make these directories world writeable. For this see the other install guides. Alternatively you can open the home directory of the nzedb user to group members and add the apache user to the nzedb group.

As root user:

usermod -a -G nzedb apache
cd /var
chgrp nzedb www  # Temp group write access for composer install
chmod g+w www

git clone nZEDb, then use Composer to install dependencies

su - nzedb
cd /var/www  # Note: The nzedb userid will need write access to /var/www
touch file && rm file                          # test write access
git clone https://github.com/nZEDb/nZEDb.git   # Needs some time
cd nZEDb
composer install --prefer-source               # Takes even longer!

# sudo chown -R www-data:www-data /var/lib/php/sessions/   # ??
chmod 755 ./
# chmod -R g+s ./            # is SUID really needed?
chmod -R 755 app/libraries
chmod -R 775 app/resources
chmod -R 775 libraries
chmod -R 775 resources
chmod -R 775 www
chmod +x ./zed
alias zed='./zed'

Note, the above section is based on this page

# Fedora specific 
sudo chgrp apache /var/www/nZEDb/resources/nzb
sudo chgrp apache /var/www/nZEDb/resources/smarty/templates_c
sudo chgrp -R apache /var/www/nZEDb/resources/covers
sudo chgrp -R apache /var/www/nZEDb/resources/tmp
sudo chgrp -R apache /var/www/nZEDb/configuration   # Is this needed?
sudo chgrp -R apache /var/www/nZEDb/_install

# Setup the settings.php for nZEDb
cd nzedb/config/
cp -p settings.example.php settings.php

Create nZEDb Database and grant user access

This step is optional as the installer can create the database for you. This method below is useful if you have other applications using the same database.

mysql -u root -p    (Default is no password)
create database nzedb;
use nzedb;
grant all privileges on nzedb.* to nzedb@'localhost' identified by 'YourPasswordHere';
grant all privileges on nzedb.* to nzedb@'127.0.0.1' identified by 'YourPasswordHere';  # just in case
GRANT FILE on *.* to nzedb@'localhost';     #  (used when loading tables from system files)
GRANT FILE on *.* to nzedb@'127.0.0.1';     #  (used when loading tables from system files)
GRANT RELOAD on *.* to nzedb@'localhost';   #  (used when optimising DB)
GRANT RELOAD on *.* to nzedb@'127.0.0.1';   #  (used when optimising DB)
flush privileges;
exit

Load timezone information into database

This information is used by the IRC scraping code.

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

tmux v2.0 (Optional)

Fedora 25 ships with tmux v2.2 which is incompatible with nZEDb. It's best to download and compile v2.0.

wget https://github.com/tmux/tmux/releases/download/2.0/tmux-2.0.tar.gz
tar -xzf tmux*
cd tmux*
./configure
make
cp -p tmux /usr/local/bin/

Last Steps

Finally, read up on this page to finish up.

Note: Don't forget to get your own API keys! (TMDB, Trakt & fanart.tv keys are important)

Clone this wiki locally