Saturday, November 26, 2011

Run a minecraft server on Debian 6

Requirements
The Minecraft server is written in java, therefore java runtime environment is required. Check your java installation with this command:
java --version
If you get an error message saying "command java not found" you can install java using this command:
apt-get install default-jre

Installation
Let's start the installation. I would recommend to create a separate user for running the server. You should not use root to run the server for security reason.
useradd -m minecraft
passwd minecraft
Create a directory for the server and download as user "minecraft" the server software:
su minecraft
mkdir server
cd server
wget https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar?

Now you can run the server directly from here or you can use a script that helps you running the server in background. You can specify the maximun and minimun amount of RAM which is used by the server. But keep in mind that java produces an overhead. In my case it's about 40% to 60% (depending on runtime and connected users).

And finally start your server:
java -Xms32M -Xmx1024M -jar minecraft_server.jar nogui
I recommend to have at least 1024 Mb for your server.