C.J. Scarlett

Installing Minecraft Server on Debian 8

Debian Logo

Preamble

Covers the general process of setting up a basic Minecraft server from start to finish. Along with how to configure some of the server’s properties and user permissions.

  • Uses Java (OpenJDK in this case) as a dependency.
  • Requires GNU Screen to maintain a shell session.
  • The Minecraft game client is necessary to test access to the server.
  • Suitable Server Hardware specifications are addressed.

Minecraft’s Official Website


1 – Update System Packages

Ensure the packages are up to date on the system with the command:

1
$ sudo apt-get update && sudo apt-get upgrade

Confirm the action by entering y for any prompts in this step.


2 — Install Screen

Screen is used to keep the Minecraft server running in a persistent shell session, it also allows us to disconnect or re-attach to the session when needed.

1
$ sudo apt-get install screen

3 – Install Open JDK

Install the open JDK platform with Debian’s package manager:

1
$ sudo apt-get install openjdk-7-jre-headless

Note: “It is recommended that Linux users avoid using OpenJDK 6 for server hosting, as it has been known to cause issues.”


4 – Create Dedicated User

Add a user with a suitable name who’ll run and store the server software in its home directory:

1
$ sudo adduser minecraft

5 – iptables Firewall

If using iptables you’ll need to allow access on the Minecraft server’s TCP port 25565 for incoming connecting clients.

Here is one command to add this, tweak it to your own needs and firewall setup:

1
$ sudo iptables -I INPUT 3 -p tcp --dport 25565 -j ACCEPT -m comment --comment "allow connections on port 25565 Minecraft server"

Remember to re-save your updated rules (IPv4 in my case).

1
$ sudo iptables-save > /etc/iptables/rules.v4

6 – Download Minecraft Server Software

SSH to the new minecraft user (or whatever you named them).

1
$ ssh minecraft@your.vps.ip.address

Download the latest version of the Minecraft server jar file.

The current version number is 1.8.8 at the time of writing this:

1
$ wget -v https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar

Note: Amend your command to include the version number that is currently in release. Previously found at https://minecraft.net/download towards the bottom of the page.


7 – Create Minecraft Executable Script

With a text editor create a shell script named something similar to the following:

1
$ vim run-minecraft-server.sh

In the newly created script add the code in the next snippet, replacing the two java parameter values with your own preferred memory usage values.

~/run-minecraft-server.sh
1
2
3
4
5
6
#!/bin/bash

BINDIR=$(dirname "$(readlink -fn "$0")")
cd "$BINDIR"

java -Xmx1024M -Xms1024M -jar minecraft_server.*.*.*.jar nogui

See the next image for recommendations on server requirements from the official Minecraft wiki, to determine your values.

Minecraft Wiki Server Requirements

-Note: Xms256M dictates the lowest amount of system memory the Minecraft server will consume, and Xmx512M specifies the upper limit of server memory it can max out at.

Save your changes to the script and exit back to the command line.

Finally in this step use chmod to make the previous script executable.

1
$ chmod +x run-minecraft-server.sh

8 – Run Executable Script

Run it from the command line by adding the ./ prefix.

1
$ ./run-minecraft-server.sh

You’ll see the following output if the script has been written correctly:

1
2
3
4
5
6
7
8
9
[09:10:50] [Server thread/INFO]: Starting minecraft server version 1.8.8
[09:10:50] [Server thread/WARN]: To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar"
[09:10:50] [Server thread/INFO]: Loading properties
[09:10:50] [Server thread/WARN]: server.properties does not exist
[09:10:50] [Server thread/INFO]: Generating new properties file
[09:10:50] [Server thread/WARN]: Failed to load eula.txt
[09:10:50] [Server thread/INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
[09:10:50] [Server thread/INFO]: Stopping server
[09:10:50] [Server Shutdown Thread/INFO]: Stopping server

9 – Agree to EULA

The EULA you must agree to is located in the same user’s home directory.

Again using a text editor open it for writing:

1
$ vim eula.txt

Set the eula directive to true like in the example below:

1
2
3
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Mon Oct 05 09:10:50 EDT 2015
eula=true

Save changes and exit the text editor.

Back on the command line begin a screen session by providing the full path to your executable script:

1
$ screen ./run-minecraft-server.sh

The server now runs and begins to generate the in-game content.


10 – Client Connections

The server should now be running continually and Minecraft clients can connect to it.

Connect with a Minecraft client to the server IP.

Everything should be functioning as intended, and the server is ready for use!

You can leave and detach from the screen session by pressing CTRL + d then a on your keyboard, back in the terminal.


11 – Administration

Logged in once again as the Linux user minecraft or whatever you chose to call your dedicated user, re-attach to the minecraft screen session from earlier with:

1
$ screen -r

Shut down the server which saves player created progress and the in-game content.

1
/stop

Now the server has been stopped you can begin to play around with its file structure.

1
$ ls

There are several key files in in regards to maintaining the server, and two other directories to consider.

Any time you modify these files while the game is running, you will need to stop and restart the server for the changes to take effect.


ops.json

This file named ops.json contains usernames of players that have ops privileges on your server.

It is empty until you add player usernames however.

Warning: Players listed in this file can change their game mode, input certain commands, and ban or unban other players from the server.

You can either add user details directly to this .json file, if you understand the formatting involved.

Or create a completely separate ops.txt file with a list of usernames inside.

1
$ vim ~/ops.txt

The text file you create is then converted into the ops.json file from earlier once the server is next booted.

It is recommended that you follow this method if you are unfamiliar with JSON formatting.

For more information on ops or operators in Minecraft click the next link:

Minecraft Wiki Operators Page


server.properties

The bulk of in-game settings and properties are stored in the following text file.

1
$ vim ~/server.properties

There are a longer list of properties you can add to the file that are listed at this next URL:

Minecraft Wiki Server.properties Page


banned-ips.json & banned-players.json

In order to ban an IP address from connecting to the server, the full IP address must be specified; - impartial addresses or wildcards are not supported here.

Any players who are banned in this manner see “Your IP address is banned from this server!” when attempting to connect through the client.

In-game an operator can instead use “/ban-ip ipaddress”, where “ipaddress” is the IP address of the user they wish to ban. To remove and undo a ban, the operator can issue “pardon-ip ipaddress”. Or if they have access, edit the server’s banned-ips.json file.


white-list.json

This essentially can be used to make a server private to a select group of clients. To do so add their usernames to the file white-list.txt. You will need to edit the server.properties file, changing white-list=false to white-list=true .

Alongside this you can also use this file to change the public message on your Minecraft server.

1
$ vim ~/white-list.txt

Edit motd=A Minecraft Server to show the name or phrase that you want to display publicly to clients.


World Directories

This directory and its subdirectories contain map and player data for the realms in your game.

It is worth backing up these directories regularly so that you can revert to previous versions in case of in-game mishaps or unwanted trolls. These directories may be in different locations, depending on which version of the Minecraft server you installed.

Also note that the directories for the nether and the end will not be created until a player visits the area at least once on the server.


Log Directory

Anything and everything that goes on is stored in the logs directory. It’s worth reviewing it’s contents every now and then or if any technical problems arise.

1
$ less ~/logs/latest.log

Previous logs are compressed automatically as and when needed.


Console Commands

The link below contains a table that summarizes all available commands. Some of which have been mentioned here, but most of which have not.

Minecraft Wiki Commands Page


More Information

Easily deploy an SSD cloud server on Digital Ocean in 55 seconds. Sign up using my link and receive $10.00 in free credit: https://www.digitalocean.com/?refcode=e91058dbfc7b

– Scarlz: @5car1z

Installing TDSM Terraria Server Mod on Debian 8

Debian Logo

Preamble

TDSM is one of several open-source server mods available for the online action-adventure game Terraria. This modification is developed to allow the Terraria server software to be run on Linux like operating systems, and opens up many other potential benefits for players using the server.

  • External plugin support.
  • Administrative permissions system.
  • MySQL & SQLite databases.
  • New & custom in-game commands.
  • Remote console administration.

It’s also updated relatively quickly by the maintainers after a new Terraria client version is released.

TDSM Github Project Page


Requirements

  • A Terraria game client for connection to the server after installation.

  • For a small sized world, a VPS that has at least 1GB RAM.

  • For a medium sized world, a VPS that has at least 1GB RAM.

  • For a large sized world, a VPS that has at least 2GB RAM.


1 – Update System Packages

Ensure the packages are up to date on the system with the command:

1
$ sudo apt-get update && sudo apt-get upgrade

Confirm the action by entering y for any prompts in this step.


2 – Install Screen

Screen will be used to keep the TDSM server running in a persistent shell session, and allows us to disconnect or re-attach to the session when needed.

Install Screen with the command:

1
$ sudo apt-get install screen

3 – Install Mono

Mono is the open source implementation of Microsoft’s .NET Framework, and we need it to successfully run and start the TDSM server later on.

Install Mono and all its packages with the command:

1
$ sudo apt-get install mono-complete

4 – Install Unzip

The server software comes packaged in a .zip file. So install the unzip package which we’ll use in the next step, to extract the files.

1
$ sudo apt-get install unzip

5 – Add Swap Space

The server mod requires adequate swap space to be allocated by the system. Otherwise this can result in crashing and instability with TDSM whilst it is running.

Create the base swap file:

1
$ sudo fallocate -l <^>4G<^> /swapfile

Give it the correct permissions it needs:

1
$ sudo chmod 600 /swapfile

Have the system build the file:

1
$ sudo mkswap /swapfile

Then enable it with the swapon command:

1
$ sudo swapon /swapfile

To automate the mounting of the swap file on boot we need to include its details into the /etc/fstab file.

1
$ sudo nano /etc/fstab

Insert this top line show in the next code snippet into the file.

/etc/fstab
1
/swapfile   none    swap    sw    0   0

6 – Download the TDSM Server Software

The TDSM server software that we’ll download in this step will be stored and run from your user’s home directory.

Make sure this is your current working directory by entering:

1
$ cd ~

As of writing this tutorial the current TDSM server build release is number: 005

For newer versions than the current 005 release, and to download the most up to date version.
You’ll need to change the URL passed to wget in the next code snippet.

1
$ wget https://github.com/DeathCradle/Terraria-s-Dedicated-Server-Mod/releases/download/Build-5/tdsm-b5.zip

The TDSM server releases and their file URL’s can be found on the project’s GitHub page:

TDSM Releases on Github


7 – Run the Terraria Server Binary

Next unzip the downloaded archive file and extract the contents into a new folder named tdsm-terraria-server using the -d option:

Note: The downloaded .zip file name will differ for future release downloads.

1
$ unzip tdsm-b5.zip -d tdsm-terraria-server

Change into the unpacked tdsm-terraria-server directory with:

1
$ cd tdsm-terraria-server

Now to run the server software in it’s most basic form without any arguments or parameters, enter the following command:

1
$ screen mono tdsm.exe

Note the inclusion of Screen in the last command. This runs the Mono program and server in a separate shell session to our original one.


8 – Create a New World

The below output (or similar) is seen upon successfully running the server binary in “Step 7 – Run the Terraria Server Binary“.

Type n and press ENTER to create a new world.

1
2
3
4
5
6
7
8
9
10
11
12
10/2/2015 2:05:20 PM Run> TDSM Rebind API build 5lr running on Mono                                                                                                                                                                            10/2/2015 2:05:20 PM Run> Logging started to file "/home/<username>/src/tdsm-terraria-server/Data/server_20151002_1405.log".
10/2/2015 2:05:20 PM Run> Loading plugin from TDSM.Core.dll.
10/2/2015 2:05:20 PM Run> TDSM Rebind core build 5lr
10/2/2015 2:05:20 PM Run> TDSM Rebind core enabled
10/2/2015 2:05:21 PM Run> Server state changed to: Initialising
10/2/2015 2:05:23 PM Run> Server state changed to: Starting
Terraria Server v1.3.0.8

n New World
d <number> Delete World

Choose World:

Enter 1 , 2 , or 3 depending upon your preference and suitability of world size.

The requirements section at the start of this article indicates what world size is suitable for your VPS.

Here it is again:

  • For a small sized world, a VPS that has at least 1GB RAM.

  • For a medium sized world, a VPS that has at least 1GB RAM.

  • For a large sized world, a VPS that has at least 2GB RAM.

Warning: Be aware that the larger the world the more memory and CPU your server will need to consume whilst the server is up and running, so be sure to select a suitable world size.

1
2
3
4
5
6
7
Terraria Server v1.3.0.8

1 Small
2 Medium
3 Large

Choose size:

Enter 1 , 2 , or 3 again once more depending upon your desired level of in-game difficulty.

1
2
3
4
5
6
Terraria Server v1.3.0.8

1 Normal
2 Expert

Choose difficulty:

Now give the new world a suitable name.

For example purposes we’re calling ours test-tdsm-server in this guide.

1
2
3
Terraria Server v1.3.0.8

Enter world name:

Wait for the new world to be generated as it outputs its progress and percentage completion.


9 – Set World Details

Once the world is created and has finished generating, choose your previously created world by entering 1 into the prompt:

1
2
3
4
5
6
1   test-tdsm-server      norm, crim, exp   Last used: 10/02/2015 10:27 AM

n New World
d <number> Delete World

Choose World:

Provide the world with a max number of players that can join the server at any one time. If you are unsure on a value, the default of 8 is a sensible choice.

Warning: Once again be aware that the more players the world has connected the more memory and CPU your server will need to consume whilst running.

1
2
3
Terraria Server v1.3.0.8

Max players (press enter for 8):

Enter a suitable port the server can transmit on, go for the default choice of 7777 if you don’t have a specific port you want to use:

1
2
3
Terraria Server v1.3.0.8

Server port (press enter for 7777):

The final two questions are up to you (forwarding and password). Forwarding with iptables is covered in this next section however.

Wait for the server to load as it outputs its progress.


10 – iptables Firewall

Now the server is up running you’ll need to de-attach from the currently active screen session with:

CTRL + a then c

If using iptables (or you intend to use it) as a firewall solution on the VPS, then open up the port number you chose in “ 9 – Set World Details”

To do this use:

1
$ sudo iptables -A INPUT -p tcp --dport 7777 -j ACCEPT -m comment --comment "allow connections on port 7777 Terraria server"

Replacing 7777 for your own chosen port number.

For any other firewall program you may use in its place perform the equivalent port forwarding/opening actions.

To now connect back to the previous screen session press:

CTRL + a then n


Conclusion

The server itself is now ready and should be open for connections via the Terraria client.

To learn how to administer, run, and configure the server properly alongside what configuration files it uses, see the Github wiki:

TDSM Project Github Wiki


More Information

Easily deploy an SSD cloud server on Digital Ocean in 55 seconds. Sign up using my link and receive $10.00 in free credit: https://www.digitalocean.com/?refcode=e91058dbfc7b

– Scarlz: @5car1z