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, but that’s not what we expect.
If you have start-up the bot you can shut it down with:
Ctrl + C
5. Setting up a systemd Unit
Create a new file called phantombot.service as root.
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.
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:
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: