Ok, I’ll admit it. I’ve been caught by the Minecraft bug. It bit me hard and of course I learned rather quickly that there is a problem with using two laptops to play Minecraft on and that is that it’s a pain in the posterior to move your save games around. In this article, I will be covering how to install Minecraft Server on a new installation of Ubuntu 9.04LTS. These instructions will work for all current versions of Ubuntu, so if you’re using something newer or something older, these instructions should get you up and running in no time.
Please note that per Notch (the Minecraft developer), running the Multiplayer server is still in beta phase so expect it to crash, be buggy and generally not work. That being said, I can personally tell you that Minecraft Server DOES work and except for a few minor gameplay glitches, the server works quite well. Please keep in mind that this is by no means an exhaustive article on all things Minecraft Server, nor is it written in stone (ba-dum-thish!) as the Minecraft Server application may change. If it does, I will make changes to this article to keep it current.
I can tell you that having your own Minecraft server is awesome and that you will never go back to playing singleplayer as you won’t have to worry about files to migrate and that your world will continue to evolve even as you are not playing. This being said, before you disconnect your Minecraft session, it is recommended to make sure that your minecraft player is somewhere safe, be it in your bunker or somewhere where baddies can’t get to you while you are away. Remember, just because you’re not logged in, doesn’t mean that the world stops.
The System Requirements for Minecraft Server have yet to be officially established however there are some guidelines that have turned up during my research into this topic. The below is a guideline only and not an exhaustive set of requirements. It’s perfectly fine if you don’t meet all of them however expect performance hits depending on how you use the server.
- Processor: At least a 1.5GHz single core chip, whichever architecture you desire.
- RAM: At least 1.5GB FREE RAM. If you use the server for anything more than Minecraft, make sure you have at least 1.5GB free RAM at full utilization.
- Disk: At least a 20Gb disk, with swap space allocated. (Using the “Use Full Disk” and “Automatically Setup Partitions” options in the Ubuntu Setup will ensure you have enough swap. Although the game isn’t that big, the save files and caching elements will be quite large so of course the more the merrier.
- Networking: 10/100 Ethernet is recommended.
- Video: Doesn’t matter. We will be running Minecraft Server in a Screen session, so there’s no need for a fancyOMGWTFBBQ video card. Save that for the rig you will play Minecraft on.
Please note: In order to take advantage of Minecraft Server, you must purchase the game from Notch at www.minecraft.net and have a username and password. You will still need to use either the Minecraft Beta standalone application or the Minecraft Beta web-based application to access your server.
This is the basic setup of a good single person Minecraft server. While the possibility exists that you may be able to run multiple connected players on the specs above, if you are planning on hosting a lot of players, you may want to consider a beefer rig. My Minecraft server uses the below stats:
- Processor: Dual Core Intel Core 2 Duo 1.86GHz
- RAM: 3.5GB DDR-2
- Disk: 80GB SATA
- Networking: 10/100/1000 Ethernet (onboard)
- Video: whatever’s on the motherboard.
This HOWTO will already assume you’ve installed your core Ubuntu Server installation and have performed no additonal steps. Login with your user account that you created during setup and perform the following steps. While you can technically prepend “sudo” to each command, I find it faster and less frustrating to just “sudo bash” and type your password once.
- apt-get update
- apt-get install openssh-server
- apt-get install screen
This will install the OpenSSH server so you can remotely manage the server. You will need a client like PuTTY (download from here) in order to access it. This will also install Screen which will contain the Minecraft server process. If you don’t install screen, you will not be able to exit the SSH session without the Minecraft server being killed off.
Now for the fun part. You will need to install Java in order to start the Minecraft server but Minecraft server will require the use of only the Sun JVM. I tried with the other JVM and it did not work at all.
- apt-get install sun-java6-bin sun-java6-jdk sun-java6-jre
In order to ensure that the java environment is correct, run the command “java -version” and make sure it matches the below text.
# java -version
java version “1.6.0_22”
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Server VM (build 17.1-b03, mixed mode)
If it shows something else, you will need to do the following:
- update-java-alternatives -l
This will list off all the various Java VMs that are installed.
# update-java-alternatives -l
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun
You will need to set the proper Java VM to use via the below syntax:
- update-java-alternatives -s java-6-sun
Now, run “java -version” again and it should show the same version information as above. If it does, you’re good to go otherwise check your error messages.
Please note that the rest of these commands are run without root privileges. NEVER EVER RUN MINECRAFT SERVER AS ROOT!
Installing Minecraft Server
If you’re this far, then you’ve got the Java VM set properly and your server is all set for Minecraft Server. You will need to download the minecraft_server.jar to your computer then use scp to put it on the server. You can download a Windows SCP client called WinSCP from this site. Copy it into your non-root user’s home directory, in my case I’m using “mcserver”.
To start the server, you will need to use the following command:
java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui
You will see a lot of text scroll past the screen and you will see it generate a new world via the console messages. Once it settles down, you can then type “help” for a list of commands.
Since we just fired it up, let’s go ahead and stop it. Type in the command “save-all” which forces the server to save the generated map, then “stop” to shut the server down.
Stopping and Starting the server
To start the server, first off make sure you are in a screen session by typing “screen -list” like below:
mcserver@mcserver:~$ screen -list There is a screen on: 2434.tty1.mcserver (01/09/2011 12:58:57 PM) (Attached) 1 Socket in /var/run/screen/S-mcserver.
This indicates that you are in a screen session. If you see “(no screens running)” then just type “screen” to start one.
Once in the screen session, type in the command shown below. This is the exact same command as when we installed it, but this time we’re not going to shut it down.
java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui
To disconnect from the screen session, hit Ctrl-A and then the D key, this will drop you back to the shell prompt where you can then type “exit” to logout. The Minecraft Server will continue to run.
To stop the server that is already in a screen session, login to the server using SSH and the non-root user. To reconnect with the screen session, type in “screen -r”. You will be reconnected to the server and can then perform the following commands:
- say Server is going down
This lets any players know that the server’s going down.
This tells the server to save the entire world.
This tells the Minecraft Server to shutdown and exit. You will be dropped to a console prompt from there you can shutdown the server or do whatever you need to do.
Other useful commands in MC Server
Console commands: help or ? shows this message kick <player> removes a player from the server ban <player> bans a player from the server pardon <player> pardons a banned player so that they can connect again ban-ip <ip> bans an IP address from the server pardon-ip <ip> pardons a banned IP address so that they can connect again op <player> turns a player into an op deop <player> removes op status from a player tp <player1> <player2> moves one player to the same location as another player give <player> <id> [num] gives a player a resource tell <player> <message> sends a private message to a player stop gracefully stops the server save-all forces a server-wide level save save-off disables terrain saving (useful for backup scripts) save-on re-enables terrain saving list lists all currently connected players say <message> broadcasts a message to all players
Quick and Easy Start script
Below is a very simple script I wrote because I kept forgetting all the java commands. In order to use it, save both lines below as a file (like “startmcserver.sh”) and then “chmod +x startmcserver.sh” so that way you can start the server simply by running “./startmcserver.sh”
#!/bin/bash java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui
Remember to keep both lines intact. It’s essentially the same Java command, but it’s easier to type.
Have fun and Happy minecrafting!