This will guide you on running a Minecraft server using a VPS.
This allows you to have more control over your server, run multiple servers (step 10), and run Discord bots too!
The Discord bot and servers can also access/read each others files easily using this setup, you just need to learn how to code mods/Discord bots to do this.
Click links below for examples:
It's not as scary as it seems! Mostly copy and paste... :) But do learn more about it when you can!
This allows you to have more control over your server, run multiple servers (step 10), and run Discord bots too!
The Discord bot and servers can also access/read each others files easily using this setup, you just need to learn how to code mods/Discord bots to do this.
Click links below for examples:
- Discord bot
- Crontab tasks (start/stop/restart/detect crashes automatically)
It's not as scary as it seems! Mostly copy and paste... :) But do learn more about it when you can!
First, you'll need to install Ubuntu on your VPS. You can do this by following the instructions provided by your VPS hosting provider.
1. Once Ubuntu is installed, you'll need to log in to the VPS using PuTTy and update the package manager's list of available packages:
2. Next, you'll need to install Java. Minecraft servers require Java to run, so you'll need to install the latest version of Java Development Kit (JDK) on your VPS. You can do this using the following command:
3. Once Java is installed, you can download the Minecraft server. You can find the latest version of the Minecraft server at: https://www.minecraft.net/en-us/download/server/, or Forge versions here: files.minecraftforge.net/net/minecraftforge/forge/
4. To download the Vanilla server, use this command:
4.1 To download the Forge installer, I would use FTP (Filezilla) to transfer the Forge installer into a directory, then cd to that directory in the VPS. Alternatively, I believe you can run the following command to download it:
4.2 To install the Forge server, run the command:
5. Once the download is complete, you can start the Minecraft server using the following command:
This will start the Minecraft server with 1GB of RAM allocated to it. You can adjust the amount of RAM allocated to the server by changing the values of -Xmx and -Xms. You'll also need to set eula=true in server.proprties, again I'd use FTP (Filezilla) for this.
6. To set up a firewall to protect your Minecraft server from malicious attacks or DDoS attacks, you can use the ufw feature, which is included with Ubuntu. To enable firewall, use the following command:
7. You can then allow incoming connections on the port that your Minecraft server is listening on (default port is 25565) by running the following command:
8. You can also block incoming connections from specific IP addresses using the deny command. For example, to block incoming connections from the IP address 192.168.1.100, you can use the following command:
9. To keep the Minecraft server running in the background even when you aren't logged in to the VPS, you can use the screen feature. To install screen, use the following command:
10. To start a new screen session, run the following command:
This will create a new screen session with the name "Minecraft". You can then start the Minecraft server within this screen session by running the java command from step 5.
11. To detach from the screen session and leave the Minecraft server running in the background, press Ctrl + A + D. To reattach to the screen session later, use the following command:
Following these steps, you should be able to set up a VPS running Ubuntu for running one or more Minecraft servers
After all of this, you'd use your favourite FTP (e.g. FileZilla) to access the VPS files, as you would normally do on a Minecraft server hosting website.
Then you can create, transfer, edit, and delete files in your VPS as you please :)
1. Once Ubuntu is installed, you'll need to log in to the VPS using PuTTy and update the package manager's list of available packages:
- sudo apt update
2. Next, you'll need to install Java. Minecraft servers require Java to run, so you'll need to install the latest version of Java Development Kit (JDK) on your VPS. You can do this using the following command:
- sudo apt install openjdk-11-jdk
3. Once Java is installed, you can download the Minecraft server. You can find the latest version of the Minecraft server at: https://www.minecraft.net/en-us/download/server/, or Forge versions here: files.minecraftforge.net/net/minecraftforge/forge/
4. To download the Vanilla server, use this command:
- wget https://launcher.mojang.com/v1/objects/bb2b6b1aefcd70dfd1892149ac3a215f6c636b07/server.jar
4.1 To download the Forge installer, I would use FTP (Filezilla) to transfer the Forge installer into a directory, then cd to that directory in the VPS. Alternatively, I believe you can run the following command to download it:
- wget https://maven.minecraftforge.net/net/minecraftforge/forge/1.16.5-36.2.34/forge-1.16.5-36.2.34-installer.jar
4.2 To install the Forge server, run the command:
- java -jar forge-1.16.5-36.2.34-installer.jar --installServer
5. Once the download is complete, you can start the Minecraft server using the following command:
- java -Xmx1024M -Xms1024M -jar forge-1.16.5-36.2.34.jar nogui
This will start the Minecraft server with 1GB of RAM allocated to it. You can adjust the amount of RAM allocated to the server by changing the values of -Xmx and -Xms. You'll also need to set eula=true in server.proprties, again I'd use FTP (Filezilla) for this.
6. To set up a firewall to protect your Minecraft server from malicious attacks or DDoS attacks, you can use the ufw feature, which is included with Ubuntu. To enable firewall, use the following command:
- sudo ufw enable
7. You can then allow incoming connections on the port that your Minecraft server is listening on (default port is 25565) by running the following command:
- sudo ufw allow 25565
8. You can also block incoming connections from specific IP addresses using the deny command. For example, to block incoming connections from the IP address 192.168.1.100, you can use the following command:
- sudo ufw deny from 192.168.1.100
9. To keep the Minecraft server running in the background even when you aren't logged in to the VPS, you can use the screen feature. To install screen, use the following command:
- sudo apt install screen
10. To start a new screen session, run the following command:
- screen -S Minecraft
This will create a new screen session with the name "Minecraft". You can then start the Minecraft server within this screen session by running the java command from step 5.
11. To detach from the screen session and leave the Minecraft server running in the background, press Ctrl + A + D. To reattach to the screen session later, use the following command:
- screen -r Minecraft
Following these steps, you should be able to set up a VPS running Ubuntu for running one or more Minecraft servers
After all of this, you'd use your favourite FTP (e.g. FileZilla) to access the VPS files, as you would normally do on a Minecraft server hosting website.
Then you can create, transfer, edit, and delete files in your VPS as you please :)