Ubuntu 16.04 LTS Setup Guide


How to setup PhantomBot on Ubuntu Linux 16.04:

You need a user which has root privileges on the server to get this working!
If you dont have root privileges, you may encounter unsolvable problems during setup.
But it is possible to get the bot running without them.

Note that this guide assumes that you are creating the botuser account for PhantomBot in the botuser group. If you change the username, be sure to take that into consideration when executing commands and configuring the service file for the OS.

1. Get Your System Ready:

First thing is to make sure, that your system is up to date. Before we install anything, we check if this is the case.

Type into the terminal or your SSH client:

sudo apt-get update
sudo apt-get upgrade

2. Setting up Java JDK:

PhantomBot requires Java to run on your machine. In this case, we will use the OpenJDK runtime which can be installed via apt-get. Use Oracle if you’re on a PI

To install the OpenJDK-Runtime we need to type the following into our terminal:

sudo apt-get install openjdk-8-jdk-headless

This will install all the necessary files we need to get PhantomBot running.

Now you can check your Java version with this command:

java -version

The output should be similar to this:

openjdk version "8-internal"
OpenJDK Runtime Environment (build 8-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 8-internal+0-2016-04-14-195246.buildd.src, mixed mode)

Now we have Java installed and can get further to install PhantomBot.

3. Create a PhantomBot User:

NEVER run this type of applications as root or root-user! Provide only necessary privileges to keep your server secure!

To create a new user and the corresponding home directory you have to type the following:

sudo addgroup botuser

sudo adduser botuser --ingroup botuser

Please take a good password! Nothing like 123 or similar are really secure!
Now we have created the user and the home directory for him.

4. Installing PhantomBot

Now we’re ready to install PhantomBot into our botuser directory.
First switch to your botuser:

sudo su - botuser

Switch to the home directory:

cd /home/botuser

Now we need to download the latest PhantomBot release:

sudo apt-get install wget

wget https://github.com/PhantomBot/PhantomBot/releases/download/vX.X.X/PhantomBot-X.X.X.zip
NOTE! Replace the X with current release version like PhantomBot-2.3.5.zip!

After the download has finished, we have to unzip the files.

sudo apt-get install unzip
unzip PhantomBot-X.X.X.zip
NOTE! Replace the X with current release version like PhantomBot-2.3.5.zip!

To make future updates a bit easier, we have to rename the PhantomBot folder.

mv PhantomBot-X.X.X phantombot

The last thing we need to do is to assign the right privileges to make the launch.sh and launch-service.sh files executable.

cd phantombot

chmod u+x launch-service.sh launch.sh
sudo chown -R botuser:botuser *

Now we are ready to launch PhantomBot. You can run the bot with:


Now PhantomBot should start and you can begin to use it. At this point you can enter the information it asks you for. As a reference, you can check the Windows guide for the bot account configuration.

Ctrl + C

5. Setting Up A systemd Unit

Create a new file called phantombot.service. I use nano, but you can also use vi to write files.
sudo nano /etc/systemd/system/phantombot.service

Paste this into the file:

After=network.target remote-fs.target nss-lookup.target



After this, we have to install the created file to run at boot as a service.

sudo systemctl daemon-reload
sudo systemctl enable phantombot

Now one last thing we need to do, is to make the commands work to start|stop|restart PhantomBot.
We have to open the sudoers file to grant our botuser the rights to run these commands.

sudo visudo

On the end of the file add this:

botuser ALL=NOPASSWD: /bin/systemctl start phantombot, /bin/systemctl stop phantombot, /bin/systemctl restart phantombot

If an error is thrown, attempt to use /usr/bin/systemctl rather than /bin/systemctl.

Now the user “botuser” should have the rights to run the specific commands to start|stop|restart PhantomBot.
Let’s try it!

Switch to our botuser:

sudo su - botuser

Then as “botuser” try:

sudo /bin/systemctl start phantombot
sudo /bin/systemctl stop phantombot
sudo /bin/systemctl restart phantombot
If you have set up all correct it will start|stop|restart PhantomBot.

After PhantomBot is started, you can find your Control Panel under “YOUR-SERVER-IP:25000/panel”.
Make sure you open the following ports on your server: 25000-25004

6. Opening the Panel Ports

Enable the firewall.

sudo ufw enable

Allow SSH connections.

sudo ufw allow 22

Open the panel ports.

sudo ufw allow 25000:25004/tcp

Extra - Backup Every 24 Hours

We can have automated backups of PhantomBot very simply just by setting up a cronjob. Just follow these instructions.

sudo apt-get install bzip2
su - botuser
cd /home/botuser
mkdir -p backup/phantombot
crontab -e

Once the crontab is open, add:

1 4 * * * umask 0007;/bin/tar --exclude=/home/botuser/phantombot/lib --exclude=/home/botuser/phantombot/web -cjf /home/botuser/backup/phantombot/$(/bin/date +\%Y-\%m-\%d-\%H_\%M_\%S_\%3N).tar.bz2 /home/botuser/phantombot/ >>/home/botuser/backup/backup_phantombot.log 2>&1

Use this to check your crontab afterwards:

crontab -l

That’s it! Now once every 24 hours, PhantomBot will create a backup of itself in /home/botuser/backup/phantombot/.

Raspberry Pi 3, Ubuntu Mate and PhantomBot
Multiple bot instances on one vps (linux)
Updating from PB to on Raspberry Pi 3
VPS Installation
Raspberry Pi 3, Ubuntu Mate and PhantomBot
Make bot restart automatically every night
Transfer db from old to new updated version?
How do I install Phantombot on Linux Mint?
Front-end for your viewers to check points | PHP Script
Possible to use Phantombot proxied behind Nginx for secure connections?
Having trouble setting up on Ubuntu
Phantombot database only works on a local installation
Problem with installing the phantombot on linux vserver
VPS Hosting for PhantomBot
Notices not running
Hosting bot on servers
Run phantombot on Ubuntu 14.04
Raspberry Pi 3, Ubuntu Mate and PhantomBot
`start phantombot` command won't work