Skip to content

Instantly share code, notes, and snippets.

@stephenl03
Last active January 26, 2017 04:32
Show Gist options
  • Save stephenl03/6176f4c3297ae069484216780d299e14 to your computer and use it in GitHub Desktop.
Save stephenl03/6176f4c3297ae069484216780d299e14 to your computer and use it in GitHub Desktop.
# Install IUS
rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm
# Remove mariadb 5.5 libs so we can install a newer version of mariadb
rpm -e mariadb-libs-5.5.50-1.el7_2.x86_64 --nodeps
# Install a bunch of packages that we are going to need
yum install boost-regex boost-devel swig gcc-c++ nmap-ncat certbot subversion tmux mediainfo memcached p7zip php56u-mbstring php56u-mcrypt php56u-pecl-imagick php56u-devel php56u-fpm-nginx.noarch php56u-opcache.x86_64 php56u-pear.noarch php56u-pdo.x86_64 php56u-gd.x86_64 php56u-mysqlnd.x86_64 mariadb101u-server mariadb101u zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel nasm re2c
# Enable some of the things we installed
systemctl enable nginx memcached mariadb php-fpm
# Install unrar
rpm -Uvh ftp://ftp.pbone.net/mirror/dag.wieers.com/redhat/el6/en/x86_64/dag/RPMS/unrar-5.0.3-1.el6.rf.x86_64.rpm
# Script to install ffmpeg
bash <(curl -sL https://gist.githubusercontent.com/stephenl03/b2cdd2c02fb85ca282239e8bb5c25ed0/raw/a0ec962445dfa335debd0e3a0ebbccc3e43173dd/ffmpeg_intall.sh)
# Install python34
yum install python34u-pip python34u-setuptools python34u
# Install this other thing for python
easy_install cymysql
# Edit php files
sed -i -r 's/^(memory_limit)\s*=.*$/\1 = 1024M/' /etc/php.ini
sed -i -r 's/^(max_execution_time)\s*=.*$/\1 = 300/' /etc/php.ini
sed -i -r 's/^(post_max_size)\s*=.*$/\1 = 64M/' /etc/php.ini
sed -i -r 's/^(;date.timezone)\s*=.*$/date\.timezone = America\/Chicago/' /etc/php.ini
# Add this stuff to /etc/my.cnf.d/mariadb-server.cnf
[server]
group_concat_max_len=8192
innodb_file_per_table=1
max_allowed_packet=128M
default_time_zone=America/Chicago
open_files_limit=24576
key_buffer_size=12M
query_cache_type=1
join_buffer_size=2M
thread_cache_size=4
innodb_buffer_pool_size=4G
innodb_log_file_size=1G
innodb_buffer_pool_instances=4
skip-name-resolve=1
binlog_format=mixed
log-bin
server_id=1
log-basename=master1
max_heap_table_size=18M
tmp_table_size=18M
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
group_concat_max_len=8192
# Edit /etc/sysctl.conf
echo 'fs.file-max = 256000' >> /etc/sysctl.conf
sysctl -p
# systemd file needs to be adjusted for mariadb
mkdir /etc/systemd/system/mariadb.service.d/
echo -e '[Service]\nLimitNOFILE = 24576' >> /etc/systemd/system/mariadb.service.d/limits.conf
systemctl daemon-reload
# Edit memcached file
sed -i -r 's/^(CACHESIZE)\s*=.*$/\1=\"1024\"/' /etc/sysconfig/memcached
sed -i -r 's/^(OPTIONS)\s*=.*$/\1=\"-l 127.0.0.1\"/' /etc/sysconfig/memcached
# Create the web directory
mkdir -p /var/www/nZEDb
chown nginx:www-data /var/www/nZEDb
chmod 2775 /var/www/nZEDb
cd /var/www/nZEDb
git clone https://github.com/nZEDb/nZEDb.git .
# Custom PHP extension for FAST yEnc decodes
cd ~/
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
cp simple_php_yenc_decode.so /usr/lib64/php/modules/
echo 'extension = simple_php_yenc_decode.so' >> /etc/php.d/40-yenc.ini
cd /var/www/nZEDb/www/admin
# Add these two lines to the file we just downloaded to ensure it isn't publicly available
require_once './config.php';
$page = new AdminPage();
# Enable sphinx in mariadb
mysql -e "SHOW ENGINES;"
mysql -e "INSTALL SONAME 'ha_sphinx';"
# Add nzedb user
useradd -c nzedb nzedb
usermod -aG www-data nzedb
# Create MySQL database and user
mysql -e "create database nzedb;grant all privileges on nzedb.* to 'nzedb_user'@'localhost' identified by 'PASSWORD';GRANT FILE on *.* to 'nzedb_user'@'localhost';GRANT RELOAD on *.* to 'nzedb_user'@'localhost';flush privileges;"
# SSL Cert stuff and firewall
firewall-cmd --add-service=https --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
cd /etc/ssl/certs
openssl dhparam -out dhparam.pem 4096
certbot certonly --standalone -d dev.nzbs4.me
systemctl start nginx
# Download the composer installer
cd ~/
wget https://getcomposer.org/installer
# Move it
mv ~/composer.phar /bin/composer
composer install --prefer-source
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment