This short guide will walk you through how to host a Telegram bot on Ubuntu VPS!
This guide assumes knowledge of the following:
To begin, you will need to provision an Ubuntu VPS server. AWS and GCP would work as well with their EC2 and compute instances but the nature of those services are such that they are slightly more complicated to work with (and unpredictable, budget-wise) so we recommend going with Ubuntu VPS from Rad Web Hosting (we are very biased towards this brand).
Once you have your VPS provisioned, SSH into your server with the following command (replace 192.0.0.1 with your server’s IP address):
ssh root@192.0.0.1
Within your server, run the update command below:
apt-get update
Next, to ensure that your bot will be running 24/7, we will be using screen to keep the process alive even when we are no longer maintaining an SSH connection to the server:
apt-get install screen
Let us next quickly create a new user that will be handling this Telegram bot. For the purpose of this guide, a Telegram bot coded in python, Simple Media Converter will be used which will be handled by the user smc. Run the following command to create this new user:
adduser smc
Give the user superuser permissions:
usermod -aG sudo smc
For the remaining part of the guide, exit from your root SSH session and login as smc instead (again replacing 192.0.0.1 with the IP address of your VPS):
ssh smc@192.0.0.1
This part will vary greatly depending on the nature of your project. For demonstration purposes, if you are following through with the Simple Media Converter project, then follow this setup guide to get the project ready.
Once the project setup is complete, initialize a new screen session with the following command (this is important if you want your bot to be running 24/7):
screen
Hit enter to continue and in this new screen, start your Telegram bot:
python3 main.py
Detach from the screen by hitting ctrl + a + d
on your keyboard. Make sure to hit all 3 at once because just hitting ctrl + d
alone will terminate your screen instead. To view the list of screens, you may use the following command:
screen -ls
To reattach to the screen, simply use the command:
screen -r
With that, your bot should now be running! This concludes the guide for hosting your very own Telegram bot on Ubuntu VPS.
You now know how to host a Telegram Bot on Ubuntu VPS server. For more information, please visit the resources listed below.
This article provides a guide for how to install and deploy FusionPBX on Debian VPS. Installing FusionPBX on a Debian… Read More
This guide will show you how to choose the best dedicated server hosting services for your business or project requirements… Read More
This article provides a guide for server administrators who want to install Plesk on VPS server with Virtualizor. What is… Read More
We are happy to to announce the arrival of Rocky Linux 9. Highly-anticipated Rocky Linux 9 brings with it numerous… Read More
With a VPS and RDP Reseller Program, you can operate your own hosting company without investing in costly servers. Instead,… Read More
Users now have additional Operating System choices to use with Ubuntu VPS servers. Ubuntu 22.04 has just been added to the… Read More