How to Install Minecraft Server on Ubuntu

Pre-requisites:-

The Ubuntu platform must be installed on your computer.

This computer could be your own or a hired one, from a server provider. In the case of a hired (remote) server, you’ll have to get its IP address, a username (usually root) and password from the provider.

Minecraft Server Set Up

1) Installation of OpenSSH server

OpenSSH is a program that’s installed on the server, in-order to facilitate communication of encrypted messages over a computer network, using the SSH protocol. This program is commonly used to provide protected access to remote Linux systems. To install this, do the following:-

Login to the Ubuntu server. In case you’re logged in as root, you need not use the ‘sudo’ command before the instructions. ‘sudo’ gives the users the security privileges of another user (root’s privileges in this case).

sudo apt-get update
sudo apt-get install openssh-server

apt-get update – This command updates the local package index with the latest changes made in the repositories.
apt-get install openssh-server – Installs OpenSSH server

In case you have a hired server, you could request the provider to install OpenSSH server.

2) Using PuTTY

To access your server in case it is a remote one, you’ll need a client like PuTTY, on your local computer. Suppose you have direct access to the Ubuntu server (if it is not a remote server), you can skip this step. You can download PuTTY from here.

Double click on the exe file to open it. Enter the IP address of the remote Ubuntu server in the Host Name box. You could give a name to your server in the Saved Sessions box and click on Save. This will save this particular entry, and you need not type in the IP address every time you connect to the server. Do not change the port number, unless your server provider tells you to. Let SSH be chosen under Connection type:. Click Open to connect.

Login using the username and password provided.

3) Installation of Screen

Screen is a program that allows managing multiple processes through one physical terminal. Each process gets a virtual window. The user can switch from one window to another and interact with the various processes. The processes managed by Screen continue to run, even if their windows become inactive. Also, Screen allows detaching from one session and attaching back to it, later, while the processes continue running. Hence, installing Screen on your server, will allow the Minecraft server to run, even if the SSH session is exited.

To install Screen, type the following:-
sudo apt-get install screen

4) Installation of Java

In case you’ve not already installed Java, or if you’ve got a version below 1.6, then you’ll need to install/upgrade the same.

If you’ve got Java installed and want to check the version, then type the following:-
java -version

You should see something like the following, along with some additional information:-
java version “1.6.0_24”

If the version displayed is 1.6 or above, then you can directly proceed with the installation of the Minecraft server. Else, you’ll have to upgrade.

Note:-
For Ubuntu 10.04 LTS and above, the sun-java6 packages have been moved to the Canonical Partner Repository. These packages are no longer available in the Multiverse section of the Ubuntu archive. To add the packages, do the following:-

Type the following for Ubuntu 10.04 LTS
sudo add-apt-repository “deb http://archive.canonical.com/ lucid partner”

Type the following for Ubuntu 10.10 LTS
sudo add-apt-repository “deb http://archive.canonical.com/ maverick partner”

For some of the distros, like Ubuntu 11.04 LTS, the ‘add-apt-repository’ command itself has been removed. The python-software-properties has to be installed, for using the command. For this, type the following:-
sudo apt-get install python-software-properties
sudo add-apt-repository “deb http://archive.canonical.com/ubuntu natty partner”

Then install Java:-
sudo apt-get install sun-java6-jre sun-java6-plugin

Here, sun-java6-jre is the Java runtime environment package, which contains the Java virtual machine, the Java application launcher and the runtime class libraries, which are required for running Java programs. The sun-java6-plugin allows the running of Java applets on web browsers, like Mozilla Firefox etc.

In case you have more than one version of Java on your system, then type the following to choose the one you want to use:-
sudo update-alternatives –config java

5) Installing the Minecraft Server

It is recommended that a separate user be created (apart from root), in-order to run the Minecraft server, say ‘minecraft’ itself. Login as root. To create the minecraft user type the following:-
adduser minecraft

This will create a user called ‘minecraft’ along with a group and a home directory of the same name. You will also be asked to enter a password, and then to retype it for confirmation. Other details, like name, phone number and more, will also be asked. While setting a password is a must, you can simply press the Enter key for the rest of the details, to enable setting the default values.

Login as the new user, by typing the following:-
su -l minecraft

At this point, you can create a folder, exclusively for minecraft, say the name is minecraft itself. This is just to keep things neat.
mkdir minecraft

Go into the new directory created, and then get the minecraft_server.jar file from minecraft.net.
cd minecraft
wget http://www.minecraft.net/download/minecraft_server.jar

—————————————————————————————————————————————————————————————-
Using FileZilla
Instead of using wget command, an easier way of moving files to and from your remote Ubuntu server would be by using an FTP client like FileZilla on your local computer. Such clients also make it easy to edit files, rather than use commands to do the same. You need to install a server-side app first. You will have to be logged in as root to do this installation.

First, install the FTP daemon on the remote server:-
apt-get install vsftpd

Once this is done, reduce your PuTTY window and get the FileZilla client from the FileZilla Project website.

Double click to open it. Enter the IP address of the remote server in the Host: box. Also enter the username and password and then click Quickconnect. The Local site: section will give you the folders and files on your local computer, and the Remote site: section will give you the directories on the Ubuntu server that you’ve just connected to.

In-order to move files back and forth, you simply need to drag and drop them, wherever required. Therefore, you could download the files to your local system first, then navigate to the required folder on the remote server using FileZilla, and drag and drop them there. You can as well edit files by right clicking on them in FileZilla itself.
—————————————————————————————————————————————————————————————-

Coming back to our Minecraft set up, ensure that you are in a screen session, by typing the following
screen -list

You should see the following with some additional details:-
There is a screen on:

In case you see “no screen running”, then type:-
screen

6) Start the server

Now start the Minecraft server by typing the following:-
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

Plenty of information will roll down the screen. Your Minecraft server will finally be up and running.

—————————————————————————————————————————————————————————————-
Suppose you do not want to type in that long java command every other time, you can as well create a start script. Such files will have a .sh extension in Linux. You can create the file on your local computer and then use FileZilla to move it into the same folder that contains the minecraft_server.jar in the remote server.

First open Notepad or any other text editor, on your local system. Copy and paste the following into it:-
#!/bin/bash
java -Xmx1024m -Xms1024m -jar minecraft_server.jar nogui

Save it as Start.sh. Drag and drop it into the same folder as the minecraft_server.jar file using FileZilla.

You then need to give it the permission to execute. For this type:-
chmod +x Start.sh

Then run it by typing the following:-
./Start.sh
—————————————————————————————————————————————————————————————-

7) Other details

In case you want to broadcast any message to the players connected to your server, then use the ‘say’ command.

To enable the Minecraft server to keep running, while you disconnect from the screen session, do the following:-
Press Ctrl+A+D
You can then logout by typing “exit”.

In case you want to stop the Minecraft server itself, assuming that you have disconnected from the screen session, reconnect back to it by typing:-
screen -r

You can then broadcast a message to players who are connected to the system:-
say The Server is shutting down.

Save all existing worlds and maps, by typing:-
save-all

Stop the server, by typing:-
stop

You can configure the server according to your needs by editing the server.properties file. You can as well modify the ops.txt, banned.txt and other files to suit your requirements. The editing can be done directly on FileZilla or by using nano command on the server itself. To edit the file simply type:-
nano filename
or
nano filename_with_full_path

After making changes, press Ctrl+O to save it. Press Ctrl+X to close it.

More details at Minecraft server files and folders.

Check the following videos for setting up of minecraft server on Ubuntu:-
Tutorial 1 – Setting up SSH

Tutorial 2 – Setting up FTP

Tutorial 3 – Setting up minecraft server

This entry was posted in How to and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>