Installation Bot

Nacht123 edited this page Apr 18, 2016 · 17 revisions

Installation Guide for pajbot

The instructions below are tested with pajbot 2.7.4 (commit #1387)

  • Ubuntu 14.04.4 LTS *no guide for uWSGI and nginx
  • Ubuntu 15.10
  • Debian 8.3

Default-Guide Setup

(make sure to change them, if you use a different setup)

  • Log Folder = /var/log/pajbot
  • Project config = /srv/pajbot/configs/pajbot.ini
  • Project Folder = /srv/pajbot
  • OS group = www-data
  • OS user = ubuntu
  • Text-Editor = subl

Requirements

pajbot Required Tested Version
GIT Yes 2.5.0
gulp Yes CLI 1.2.1
MySQL Yes 5.6
nginx No 1.9.14
Node Yes 5.10.1
NPM Yes 3.8.6
PM2 No 1.1.1
Python Yes 3.4
Redis Yes 3.0.7
uWSGI No 2.0.12

If you stuck at some point, checkout this video.

1. Create a Project Folder

# Debian (Allow the user ubuntu, to execute sudo)
su
adduser ubuntu sudo
exit

# You maybe need to restart Debian
# create a folder for pajbot in /srv/
sudo mkdir /srv/pajbot
sudo chown ubuntu:www-data /srv/pajbot
cd /srv/pajbot

2. GIT

# Install git
sudo apt-get install git

clone pajbot

# in /srv/pajbot
git clone https://github.com/pajlada/pajbot.git .

or if you Fork it

# in /srv/pajbot
git clone https://github.com/YOUR-USERNAME/pajbot.git .
git remote add upstream https://github.com/pajlada/pajbot.git

3. MySQL (Guide)

Install MySQL

sudo apt-get install mysql-server

Login to MySQL & Create a MySQL Database

mysql -u root -p

CREATE DATABASE pajbot CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES ON pajbot.* TO 'pajbot'@'localhost' IDENTIFIED BY 'password';

exit

4. Python Requirements

4.1.1 For Python venv (Guide)

sudo apt-get install python3.4-venv python3-dev

4.1.2 For cryptography module (Guide)

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

4.1.3 For pillow module (Guide)

# Ubuntu 14.04 LTS, Ubuntu 15.10, Debian 8
sudo apt-get install libtiff5-dev zlib1g-dev \
    libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev \
    python-tk python3-tk

and

# Ubuntu 14.04 LTS, Ubuntu 15.10,
sudo apt-get install libjpeg8-dev 
# Debian 8
sudo apt-get install libjpeg62-turbo-dev

4.1.4 For PyAV module (Guide)

Packages required for thumbnail-generation

sudo apt-get install \
    libavformat-dev libavcodec-dev libavdevice-dev \
    libavutil-dev libswscale-dev libavresample-dev

4.2 Install a virtual environment

remove the # if you want to use the pip module

configure pip-requirements.txt

# in /srv/pajbot
./install/venvinstall.sh

5. Redis-server (Quickstart)

Debian 8 Jessie (Guide)

# add these two lines to your /etc/apt/sources.list file
deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all

wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg

sudo apt-get update
sudo apt-get install redis-server

Ubuntu 15.10

sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server

6. RUN pajbot - Bot

6.1 Create a config file according to the specifications in wiki and save it in configs/pajbot.ini

# Start myvenv
source myvenv/bin/activate
# Start the bot
./main.py
# or if your config file is in configs/pajbot.ini
./main.py --config configs/pajbot.ini

7. NODE (Guide)

Install

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs

8. NPM (Guide)

Update

Node comes with npm installed so you should have a version of npm.
However, npm gets updated more frequently than Node does, so you'll want to make sure it's the latest version.

sudo npm install npm -g

9. gulp (Guide)

Install

sudo npm install --global gulp-cli

10. RUN NPM

# in /srv/pajbot
npm install

Semantic Install

semantic

gulp build

# in /srv/pajbot
./install/gulpbuild.sh

11. RUN pajbot - website

# Start myvenv
source myvenv/bin/activate
# Start the website
./app.py
# or if your config file is in configs/pajbot.ini
./app.py --config configs/pajbot.ini

12. PM2 (Guide) (optional)

Install

sudo npm install pm2 -g

Create a log folder

sudo mkdir /var/log/pajbot
sudo chown ubuntu:www-data /var/log/pajbot

Run PM2

# Start myvenv
source myvenv/bin/activate

./startbot.sh pajbot

13. uWSGI (Guide) (optional)

(This Guide for uWSGI doesn't work for Ubuntu 14.04)

Install

# Start myvenv
source myvenv/bin/activate
# Install uWSGI
pip install uwsgi

uWSGI config

  • Example for /srv/pajbot/pajbot.ini
  • Example for /etc/systemd/system/uwsgi.pajbot.service
# Create a uWSGI config file
subl /srv/pajbot/uwsgiconfigs/pajbot.ini
# Create a uwsgi service file
sudo subl /etc/systemd/system/uwsgi.pajbot.service
# Start uWSGI service
sudo systemctl enable uwsgi.pajbot.service
sudo systemctl start uwsgi.pajbot.service

14. Nginx (optional)

Install Mainline version 1.9.14 (Guide)

You can use a different Version, but i tested it with 1.9.14

wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key
rm nginx_signing.key

# change this file
sudo subl /etc/apt/sources.list

for Debian 8.4 Jessie /etc/apt/sources.list file
deb http://nginx.org/packages/mainline/debian/ jessie nginx
deb-src http://nginx.org/packages/mainline/debian/ jessie nginx

for Ubuntu 15.10 Wily /etc/apt/sources.list file
deb http://nginx.org/packages/mainline/ubuntu/ wily nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ wily nginx

sudo apt-get update
sudo apt-get install nginx

Nginx config (Guide)

You can use this Example, to run it.
Change and update the config for your own domain settings.

sudo subl /etc/nginx/conf.d/default.conf

15. GO (optional)

Ubuntu (Guide)

sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable
sudo apt-get update
sudo apt-get install golang

Debian

sudo apt-get install golang

mkdir $HOME/go
export GOPATH=$HOME/go

16. Relaybroker (optional)

# in /srv
git clone https://github.com/gempir/relaybroker.git
cd relaybroker/

configure config.example and rename it to config.go

go get
go build

configure your config file from pajbot

[main]
;if you want to use https://github.com/gempir/relaybroker
relay_host = 127.0.0.1:7353
relay_password = test

Start Relaybroker

./relaybroker
# If you use PM2
pm2 start ./relaybroker --output="/var/log/pajbot/relaybroker.log" --error="/var/log/pajbot/relaybroker.err"