User:Asuandrew/Server

= Minecraft Alpha Server + Virtualbox =

Overview
The purpose of this text is to show the minimum required steps to install a vanilla Minecraft Alpha server in a virtual server to use in a test environment. It is also possible to use this configuration to host a live server on a VPS/dedicated server. If you are not very familiar with running your own server, I strongly suggest not using a VPS/ded, yet. Although it is possible to use this configuration on a VPS/ded, it does not take in to account any security issues.

Pros

 * A single guide that will work for any operating system that Virtualbox can be installed on.
 * More control over resources used by the Minecraft server.
 * Easy to maintain.
 * Fast setup.

Cons

 * May be difficult for inexperienced users to install.
 * More difficult to run on a low-end machine.

Virtualbox
This is the virtual server software. Download here.

Debian
To install the operating system, you need an installation disk image. Using this mirror list, select a  mirror  closest to you. For a 32 bit image, look for a file named  debian-505-i386-netinst.iso (recomended). For a 64 bit  installation, look for debian-505-amd64-netinst.iso. If you don't  know which one to choose, use the 32 bit image.

Example paths: http://debian.osuosl.org/debian-cdimage/current/i386/iso-cd/debian-505-i386-netinst.iso http://debian.osuosl.org/debian-cdimage/current/amd64/iso-cd/debian-505-amd64-netinst.iso

Minecraft
Download the minecraft_server.jar from here here. Do not download this yet!

There are other pieces of software, called packages, that you will be required to install once Debian has been installed.

Virtualbox
Find the installation instructions for your operating system here.

Start off by creating a new virtual machine in Virtualbox. Do this by clicking the new button on the top left.

Set the Operating System as Linux and the Version to Debian. After this, it will ask you how much memory you would like to dedicated to the  vm. Set this to whatever you like. You can always change it later. Next is hard disk creation. You can't change the maximum size of the disk later on without reinstalling. If you don't know how much to put, just use the default (8 GB).

You should have a new vm showing up on the left panel in Virtualbox. Select it, then choose click Settings. This is where you can change the memory, number of processors, and network settings. For now everything should be ok except for the network settings. Select the Network option on the left and change Attached to to Bridged Adapter.

And finally, you need to mount the cd image that you downloaded earlier. Use the Virtualbox documentation from here.

Debian
The installation documentation can be found here. At the top of the page, there are links to installation guides. I'm not going to walk through the entire install here, but I will point out some of the more important settings.

Start your vm once you have completed the above steps. If you did everything correctly and mounted the install cd, you should see an Installer boot menu screen. Choose the first or second option. It's going to ask you for a few different configuration settings. Keep going until you are asked to partition the hard disk. Refer to the above documentation if you have any questions about setting this up.

When asked to create a new user, choose whatever name you would like. You will be using this account to run the Minecraft server.

Choose any mirror from the list. It doesn't have to be the same one you used to download the install image.

When you get to a Software selection screen, uncheck all of the options.

After that, you will be asked if you want to install grub. Say yes and this completes the install. Don't forget to unmount the install image after you're done.

Post-installation
Once your virtual machine has finished starting up, login using root as the username and the password you provided during setup (don't worry, we're not going to run Minecraft as root).

Network
Using the Virtualbox window is kind of clunky. There's better free terminal programs out there that allow you to remotely manage your server. The most popular one for Windows is PuTTY. To be able to use PuTTy, or any other software you prefer, there are a couple of things we need to do. First, you need to install what's called a ssh server. Do this by typing in:


 * 1) apt-get install openssh-server

Press enter when it asks if you want to install additional software. Now we need to give your server a static address. To do this, type:


 * 1) nano /etc/network/interfaces

This will open a configuration file. On the last line of this file, you should see something that says:

iface eth0 inet dhcp

Replace dhcp with static.

Below this, you will add four more lines.

netmask 255.255.255.0 address 192.168.0.10 broadcast 192.168.0.255 gateway 192.168.0.1

netmask - Don't worry about this, leave it like it is above.

address - This is the address you want the server to have. Important: If you are behind a router, people using the internet will not be able to connect to you using this address.

broadcast - Replace the last set of numbers from your server's address with 255.

Example:  address X.X.X.10 broadcast X.X.X.255

gateway - This is your router's address.

Once you've finished typing all of that in, press control+o, enter, control+x. This saves and exits the program. Now you need to tell the server to use the new address. Do this by typing:


 * 1) ifdown eth0
 * 2) ifup eth0

Now open Putty and enter the address you gave your server from earlier into the Host Name field. Then click open. You should be prompted with a login just like the one when you first started your virtual machine. If not, something went wrong. Use the same login and password.

Java / Minecraft
Next, we need to install java-jre. To do this, type:


 * 1) apt-get install openjdk-6-jre-headless

Again, press enter when it asks to install additional software. You should now have everything you need to run the Minecraft server.

You should have created an additional user when first installing the operating system. We're now going to download and run the server using their permissions. Type:


 * 1) su user name

where user name is the one you created earlier. Next, type:

$ cd

Notice the change from # to $. You should no longer be running as a privileged user. This will take you to user name's home directory. After that, go to the minecraft URL provided above. There should be a link to the minecraft_server.jar. Copy the link location. After that, you will use a program called wget to retrieve the file.

Example:

$ wget http://minecraft.net/download/minecraft_server.jar?v=1283401353409

To get rid of the ?v=1283401353409, type:

$ mv minecraft_server.jar?v=1283401353409 minecraft_server.jar

The v= part will change depending on which version you download (I think).

It's finally time to start the server!

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

Xms - Initial memory.

Xmx - Maximum memory.

When you run the server for the first time, it will create all of the configuration files. Press control+C to stop the Minecraft server so that you can edit the server's configuration files. Edit the server.properties file by typing:

$ nano -w server.properties

It will look like this:

online-mode=true server-ip= server-port=25565 max-players=20 level-name=world
 * 1) Minecraft server properties
 * 2) Wed Sep 01 19:31:16 CDT 2010

Restart the server using the command above once you are finished editing that file. Look around at the other configuration files and change them if you want to. Other than that, you are done. You can now connect to your server using the address you provided above.

Block quote Block quote Block quote Block quote ====Backups====

It's very easy to create automated backups via cron on Debian. The following instructions will show what packages you need to install and which files you need to edit. The configuration I provide below will create a full backup every hour and writes to a single 7zip archive. I do it this way to save space. If you would like to keep multiple backups, you can create scheduled tasks on your home computer to download the backup file every hour.

Important This will not create multiple backup files. One archive will be continually updated

If you would like to change when the cron jobs run, refer to the cron documentation.


 * 1) apt-get install p7zip-full

The command we will be adding to the hourly cron job is:

$ 7za a -tzip -o/home/backup world.bak.zip /home/mc/world/

Where /home/backup is the full path to the directory you want the archive stored and /home/mc/world/ is the folder where your Minecraft server map folder is stored.

If you are logged in as root, type:


 * 1) su minecraftusername

Where minecraftusername is the one you created during installation. To actually edit your cron jobs, type:

$ crontab -e

On a new line enter:

0 * * * * /usr/bin/7za a -tzip -o/home/backup world.bak.zip /home/mc/world/

That's it. You can change other options if you'd like. For example, you can add a password to your archive. This can be useful if you want to publish your backups on the web. The next section will show you how to do this.

Web
The purpose of this is to make your backup files web accessible. There are many ways to do this. This way is very simple and shouldn't cause very many problems.

First, you need to install the web server. In this example, I'm going to use Apache. There are a lot of other different web servers to choose from, but this is the most popular.


 * 1) apt-get install apache2

Then:


 * 1) cd /etc/apache2/sites-enabled/
 * 2) nano -w 000-default

If 000-default is not there, edit which ever file is. Find the line that says DocumentRoot /var/www/. Change the /var/www part to the directory you made earlier for storing backups. Using the example above,

DocumentRoot /home/backup

Restart the webserver:


 * 1) /etc/init.d/apache2 reload

This points the web server to the right spot, but it probably won't be able to read the directory. You need to give it read permissions by typing:


 * 1) chown www-data:minecraftusername /home/backup
 * 2) chmod g+r /home/backup

The server should now work and you will be able to see your world folder backups.

VPS / Dedicated Server
You can skip most of this guide if you're going to be installing on a VPS/dedicated server. Start from the Java / Minecraft section.