So you want to build your own Minecraft server? Minecraft can be a pretty easy game to set up on a VPS. It just requires a few quick commands before you’re on your way to survival/adventure/creativity!
Note: This guide is specific to CentOS cPanel servers, but can be followed for a non-cPanel server as well. Also, this tutorial assumes you are familiar with working on the command line on your server via SSH. If you’re not, you might want to check out this article first to get your feet wet.
Also note: This tutorial does not include purchasing and installing the Minecraft stand-alone launcher. If you are new to Minecraft, download the launcher here to connect to your Minecraft server installation.
Without further ado, here are the steps to install Minecraft on a cPanel VPS:
Step 1: Install Java
Minecraft is a Java-based game and so we will need to install Java. cPanel offers Tomcat, which runs Java, but I would recommend installing it via the command line. You will need root-level access to the server to install Java. Here is how to set up a cPanel account that can escalate to root.
Once in the server as root you should install either java-1.6.0-openjdk or java-1.7.0-openjdk:
yum install java-1.7.0-openjdk
java-1.6.0-openjdk in the yum install command if that is your preference.
Step 2: Configure your server
Now lets prepare for the game itself. The next few commands will create a Minecraft directory in the account where we want to host Minecraft and take us to the new directory:
mkdir -p /home/account/Minecraft
/account/ is the name of the account in which you wish to install Minecraft.)
Step 3: Download and start Minecraft
- Download the game with the following command:
- Rename the file:
mv minecraft_server.1.7.2.jar minecraft_server.jar
- Start Minecraft in Java:
java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
The version at this time of writing is 1.7.2, but the process will remain the same with future versions. You can find out the latest version by visiting the Minecraft download page.
Step 4: Relaunch Minecraft
Now you should see from the rolling text on the command line that the game is starting and generating the world. This confirms that you have successfully installed Minecraft, but there are a few things we should do before we log in and start crafting and mining. The first thing is… stop the Minecraft server and restart it in a screen so we can log out of the VPS without stopping the game.
stop screen java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui
Now Minecraft is running in a screen, which means you can exit the server without the game closing on you. You can do this by detaching the screen:
[ctrl] + a [ctrl] + d
If done successfully you should get a message that says
If you don’t want to alter the default settings, you are now done. If you do, read on…
Step 5: Configure Minecraft
If you want to get a little deeper into the Minecraft setup you can add the IP for your server, your world name, or the message of the day.
- To make any configuration changes you will need to stop the game though, so re-attach the screen:
screen -r stop
- Then you will want to edit at least the server.properties file and probably the opts.txt file.
Note: If you want to edit the files via FTP or cPanel you may need to change their permissions. If you do, run:
chown -R account:account /home/account/Minecraft
The ops.txt file controls who has administrator powers while in the game, so place the Minecraft accounts you want to have administrator power in that file. The server.properties file is the big one, it is going to have game options and settings in there. The settings I am going to set are:
level-name=ServInt server-type=LARGEBIOMES server-ip=220.127.116.11 pvp=false motd=Welcome to Minecraft
- There are lots of other options that you may set: whether or not you have the nether, level-seed to generate a specific Minecraft map, and game mode are just a few examples. Here is a link to all of the options and their settings.
- After you have your server configured, it would be wise to create an init script to easily restart the game and make it so that you can restart it on boot. Check out this template for just such an init script. You must edit it and place the init script in /etc/init.d/ . It will not work if you simply copy/paste it.
The fields that you need to edit are:
USERNAME= WORLD= MCPATH=
The USERNAME field will be the cPanel account that you have Minecraft installed in, WORLD is the name of the world/directory, and MCPATH is where your Minecraft installation is, something like /home/account/Minecraft. You can then start, stop, restart and set it to start on boot with these two commands:
/etc/init.d/minecraft restart chkconfig minecraft on
You can check your work by using
chkconfig --list. Then you can start the server back up and log in to the game.
In case you’re interested, the Minecraft server I set up that a bunch of us play on at ServInt is available on IP 18.104.22.168. Come and join us.
Final note on support: This software falls outside the scope of support we provide for our managed products at ServInt. With that said, we have several employees that are enthusiastic about Minecraft. While we cannot guarantee results, nor a timely response, these employees are typically happy to look over a problem if you submit a ticket in your customer portal. ServInt also recommends no less than a Signature VPS to run Minecraft, due to the stringent memory requirements.
Photo by Daniel Jurena