Minecraftserver on Raspberry PI2

Now for something different. I wanted to setup a Minecraft server so my kids could play with their friends. There are many guides how to do this but I had to look at many places to get a good start. Notice that I have not really played Minecraft myself. I am more interested to see if it could work on my Raspberry Pi 2. I have also only tried this with just a few users on line. For larger setups you may need a more powerful server.

1. Setup the PI

The first step would be to get the pi, some memory and a case put together. Before the ssd card is used insert it in your windows computers sd card reader.

Download the Win32DiskImager software here. There are very good details on the pi official homepage how to do this as well. Also download Rasbian as your os. I tried the Ubuntu snappy os first but found out that it was more simple to use Raspbian.

After the downloads has finished open up and write the image to your sd card like below. Make sure you use the right path.

win32-imagewriter

 

 

 

 

 

 

 

Now put back the sd card and power up. During my setup I never used any monitor at all. All steps should work by accessing the Pi remote.

2. Configure the PI

Now it is a good idea to connect to your router and look under dhcp clients to find out what ip address the device have.  You could set your Pi to a static address or just set in your router that it will get the same ip address next time with a reservation. I find it easier the second way.

In my case I got the address 192.168.0.66. I use putty to connect. Default user name is pi and raspberry. First of all change your password. You will open up ports later on and you don’t want anyone unkown to be able to login.

passwd

After this you can remove all gui related things as well as some other stuff that you may not need. It might free up some memory needed for other things.

sudo apt-get -y purge xserver* x11-common x11-utils x11-xkb-utils x11-xserver-utils xarchiver xauth xkb-data 
console-setup xinit lightdm libx{composite,cb,cursor,damage,dmcp,ext,font,ft,i,inerama,kbfile,klavier,
mu,pm,randr,render,res,t,xf86}* lxde* lx{input,menu-data,panel,polkit,randr,session,session-edit,shortcut,
task,terminal} obconf openbox gtk* libgtk* alsa* python-pygame python-tk python3-tk scratch tsconf
desktop-file-utils
sudo apt-get -y autoremove
sudo apt-get -y clean

3. Setup MCServer

When this is finished it is time to download the server. I have used MC Server. There are many unofficial servers but this server is written in c++

wget http://builds.cuberite.org/job/MCServer%20Linux%20armhf/lastSuccessfulBuild/artifact/MCServer/MCServer.tar
tar -xvf MCServer.tar

You may put the directory anywhere you want. I put mine in home/pi/MCServer

You can try to start the server if you want just to make sure it works. It will take some time the first time as the world will have to generate.

./MCServer

As you already may have figured out…..

screen -dmS minecraft ./MCServer

4. Using Supervisor for automatic startup and restart.

There is another way of doing this with the supervisor program. This program takes care of different processes and restarts them if necessary.

First install supervisor

sudo apt-get install supervisor

Create a script that will be launched from supervisor

cd /home/pi/MCServer
sudo vi mc mcserver.conf

Add the lines below in the file

#!/bin/sh
cd /home/pi/MCServer
./MCServer

Configure a configuration file for the server in supervisor

sudo vi /etc/supervisor/conf.d/mc.conf

Add the lines

[program:mc]
command=/home/pi/startmcs.sh
user=pi
autostart=true
autorestart=true

Now it is time to see if it works. You will have to reload the supervisor config files and make sure that no error occurs.

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl update
sudo service supervisor restart

Run the status command. If everything is correct you will see this.

sudo supervisorctl status

sv1

You can use top to see the id of the process of the MCServer. If you want to you may use “kill ID” and after this try top again. It will be started by supervisor. Also you can restart the server and it will be started after boot.

So the PI is up and running, MCServer is installed and it starts up automatically.

5. Using the webgui and other things

There are some things you may want to change and some things that may be a little bit confusing. Most changes will be done from the webgui that you can access from http://ipofyourpi:8080. However you will have to edit the file webadmin.ini first in the MCServer directory. Change password and set enabled to =1.  Now it should work.

Most settings are configured in the file settings.ini. However most of the settings will be availible in the gui. It will look like below. Here you can create new worlds, change time or weather and make users admins.

mcs2

One thing I did was to import an existing world into MCServer. Simply copy the folder world or whatever it is called and place in the MCServer directory. You may want to change the spawn point and this can be done in the webbgui. Press F3 on your old world to get the coordinates. Insert them in the copy of the world. Edit the [worlds] and add like below.

[worlds]
Defaultworld=world
world=newworld

You can now use some commands to do different things.

/gamemode 1
/portal myotherworls
/tp otherplayer

More command below.

https://github.com/mc-server/Core/blob/master/README.md

 

 

 

0 0 vote
Article Rating
0
Would love your thoughts, please comment.x
()
x