You need a user which has root privileges on the server to get this working! If you don't have root privileges, you may encounter unsolvable problems during setup. But it's possible to get the bot running without them.
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:
2. Setting up Java JDK and other requirements
PhantomBot requires Java to run on your machine. In this case, we will use the OpenJDK runtime which can be installed via yum.
To install the OpenJDK-Runtime and the other requirements we need to type the following into our terminal:
yum install java-1.8.0-openjdk-headless.x86_64 wget unzip bzip2
This will install all the necessary files we need to get PhantomBot running.
Now you can check your Java version with this command:
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:
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, add the bot to the
usermod -G wheel botuser
Then switch to your botuser:
su - botuser
Switch to the home directory:
Now we need to download the latest PhantomBot release:
Replace the X with the current release version like PhantomBot-2.3.5.zip!
After the download has finished, we have to unzip the files.
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.
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.
After the bot is configured you can press the following keys and follow the rest of the guide.
Ctrl + C
5. Setting up a systemd Unit
Create a new file called phantombot.service as root.
Paste this into the file:
[Unit] Description=PhantomBot After=network.target remote-fs.target nss-lookup.target [Service] User=botuser Group=botuser Restart=on-failure RestartSec=30 ExecStart=/home/botuser/phantombot/launch-service.sh KillSignal=SIGTERM [Install] WantedBy=multi-user.target
After this, we have to install the created file to run at boot as a service.
systemctl enable phantombot
Now one last thing we need to do, is to make the commands work to start|stop|restart|status PhantomBot.
We have to open the sudoers file to grant our botuser the rights to run these commands.
On the end of the file add this:
botuser ALL=NOPASSWD: /bin/systemctl start phantombot, /bin/systemctl stop phantombot, /bin/systemctl restart phantombot, /bin/systemctl status phantombot
Now the user “botuser” should have the rights to run the specific commands to start|stop|restart|status PhantomBot.
Let’s try it!
Switch to our botuser:
su - botuser
Then as “botuser” try:
sudo systemctl start phantombot
sudo systemctl stop phantombot
sudo systemctl restart phantombot
sudo systemctl status phantombot
If you have set up all correct it will start|stop|restart|status 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:
6. Opening the Panel Ports
First you’ll want to enable your firewall. Centos 7 can have it disabled by default, even when disabled the ports won’t be opened.
sudo systemctl enable firewalld
Then you’ll want to start the firewall.
sudo systemctl start firewalld
After that you can open the ports.
sudo firewall-cmd --zone=public --add-port=25000-25004/tcp --permanent
Reload the firewall after to apply your changes.
sudo firewall-cmd --reload
Extra - Backup every 24 hours
su - botuser
mkdir -p backup/phantombot
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: