For those that are interested I will make one of my machines available for practice. I will install Ubuntu and give you root level access, the rest will be up to you. This is a first come first server offer, so everyone will have to take turns.
You will need the following to use this tutorial:
A home network already configured and working properly.
A machine you can install Ubuntu on, this doesnt have to be extremely powerful.
A different machine you can use to play Minecraft on.
Some basic Linux command line knowledge such as navigating the file system.
An FTP client, I suggest FileZilla.
An ssh terminal you can run from your Windows machine. I suggest Poderosa.
Install Ubuntu 10.04 LTS with the following software packages
When installing LAMP it will ask you for a password for the root MySQL user. Choose something complex and random, and write it down.
Login to your server and run the following command to get the IP address of your box. My machine is named ubuntu and my username is grneyeddvl.
The IP address of the machine in my example is 10.100.128.23, which is assigned by my server. Yours is probably 192.168.0.xxx. Whatever it is, write it down.
Now we are going to add a usergroup, and a user to run Minecraft with. This user will not have root level access in case your machine gets compromised.
sudo addgroup mcusers
sudo adduser minecraft
Now add the minecraft user to the mcusers group.
sudo adduser minecraft mcusers
You now have a user named "minecraft" that belongs to the usergroup "mcusers". The reason we are creating the mcusers group is in case you want to add administrators to your machine later. We can give permissions to the mcusers group and your new user will inherit them, and will not have root access to the box.
Now we are going to create folders for minecraft, and folders for backups. Most tutorials have you create these in your home directory, but we are not going to do that as we want other users to be able to access them in the future. We are going to create a minecraft folder and a mc_backups folder in the root of your drive. These are the steps, you might want to clear your screen first by typing the command "clear" without quotes.
The process is as follows:
Change directory to the root: cd /
Create minecraft folder: sudo mkdir minecraft
Create mc_backups folder: sudo mkdir mc_backups
List the folders to make sure they appear properly: ls
You should see the minecraft and mc_backup folders listed.
Now we are going to change the ownership of the minecraft and mc_backup folders to your minecraft user and your mcusers group. We also need to make sure this is recursive so that all new files created have the same owners, we will use the -R tag for this. The command for this is chown (change ownership) and the syntax is as follows:
sudo chown -R user:group folder/file
Run the commands and then run ls -l to see that they are properly executed:
You will see that the folders list minecraft as the user and mcusers as the group.
Now we are going to create a few more folders, so we can run multiple Minecraft servers off of this machine without them conflicting. One will be a Creative server, one will be a PvP server for our example. So navigate to your minecraft folder and create two new folders: creative and pvp, then run the ls command and make sure they appear.
Now loadup FileZilla and connect to your box. Place the latest build of CraftBukkit in the creative folder and in the pvp folder and MAKE SURE YOU RENAME THEM. You cannot run them both at the same time if they have the same name. I named mine mc_creative.jar and mc_pvp.jar.
Now that your Bukkit server files are on the machine and ready to run, we need to install Java. Ubuntu 10.04 does not come with Java installed, and its not part of the package distribution by default. This means we need to install python and update the repository list before we can install Java. Run these commands in this exact order, and press Y when it asks you a question.
PRESS TAB KEY TO SELECT OK and YES when this one pops you some questions.
Now we are ready to run Bukkit for the first time. logout of your ssh client, and log back in as your minecraft user. We need to run the server to create the default files, and to make sure your user works. Navigate to your minecraft/pvp folder and run this command. The numbers are how much RAM to allocate, I used 2048 or two gigs. Put your own numbers in if you wish. You will know it is working when you see the console start spitting out Minecraft stuff. MAKE SURE YOU RUN THE COMMAND WITH THE SAME FILENAME YOU USED WHEN YOU UPLOADED YOUR FILES!
Spoiler Alert, click show to read:
[email protected]:/minecraft/pvp$ cd /minecraft/pvp [email protected]:/minecraft/pvp$ java -Xmx2048M -Xms2048M -jar mc_pvp.jar
21:44:41 [INFO] Starting minecraft server version Beta 1.7.3
21:44:41 [INFO] Loading properties
21:44:41 [WARNING] server.properties does not exist
21:44:41 [INFO] Generating new properties file
21:44:41 [INFO] Starting Minecraft server on *:25565
21:44:41 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-980-g4ed23b1-b1060jnks (MC: 1.7.3)
21:44:41 [WARNING] Failed to load ban list: java.io.FileNotFoundException: banned-players.txt (No such file or directory)
21:44:41 [WARNING] Failed to load ip ban list: java.io.FileNotFoundException: banned-ips.txt (No such file or directory)
21:44:41 [WARNING] Failed to load ops: java.io.FileNotFoundException: ops.txt (No such file or directory)
21:44:41 [WARNING] Failed to load white-list: java.io.FileNotFoundException: white-list.txt (No such file or directory)
21:44:41 [INFO] Preparing level "world"
Open up Minecraft on your desktop and try to connect. The default port is 25565 so in my case the address is 10.100.128.23:25565
As long as you can connect and move around that is all we care about at this point. We havent changed any settings at all, and we need to get the default folders and files created in the creative folder now as well.
Type the command "stop" into your ssh console and Minecraft will exit. Navigate to your creative folder and run the same command with the proper file name. You should get the same Minecraft console as you did when you ran the pvp file. Connect to it if you want, and then stop the server using the stop command.
Now if you run the ls command from inside either the pvp or creative folder, you will see a normal looking file structure for a Minecraft server.
[email protected]:/minecraft/creative$ cd /minecraft/pvp
[email protected]:/minecraft/pvp$ ls
banned-ips.txt banned-players.txt bukkit.yml mc_pvp.jar ops.txt permissions.yml plugins server.log server.properties white-list.txt world world_nether
The next thing we need to do is use a text editor to change the server.properties file and to add yourself to the ops.txt file. You can connect with your FTP client again and download those two files, edit them, and then upload them again, or you can use one of Ubuntu's built in text editors. I prefer to use nano over vi as its much easier to use.
MAKE SURE YOUR TWO FILES HAVE DIFFERENT PORT NUMBERS! Highlighted in red.
Now that we know both versions of your server work, we need to set it up so they will both run at once, and so that they will automatically run when the server boots. To do this you need to use a script. I have attached a couple of versions of the script to this post. Download that and change as needed.
Now these files need to go in the /etc/init.d folder, but you cannot write to that folder with SFTP. You need to upload them someplace you have permissions for, and then move them into the etc/init.d folder with the sudo mv command. I suggest putting them into their Minecraft folders for now, so the mc_creative goes in /minecraft/creative and the mc_pvp goes in /minecraft/pvp. Then login to your Ubuntu server as your original user, your minecraft account does not have sudo rights.
Go to minecraft/pvp
Check to make sure the file is there
Move the file
[email protected]:/minecraft/creative$ sudo /etc/init.d/mc_pvp start
ls: cannot access /minecraft/pvp/world: No such file or directory
created link for world
ls: cannot access /minecraft/pvp/world_nether: No such file or directory
created link for world_nether
world copied to ram
mc_pvp.jar was not running... starting.
mc_pvp.jar is now running.
[email protected]:/minecraft/creative$ sudo /etc/init.d/mc_creative start
ls: cannot access /minecraft/creative/world: No such file or directory
created link for world
ls: cannot access /minecraft/creative/world_nether: No such file or directory
created link for world_nether
world copied to ram
mc_creative.jar was not running... starting.
mc_creative.jar is now running.
You should now be able to start Minecraft and connect to both of them, even though you cannot see the console running. Try it and make sure. Remember to use the correct port numbers, my two connections are:
Login to your ssh client as your minecraft user. Run the following commands to access the Minecraft console:
screen -r pvp
screen -r creative
When you run either of those, you will be able to watch the game realtime from your ssh client. You can even enter commands such as stop, reload, say, etc. When you want to exit the console press:
Ctrl + A + D
This will give you back your shell prompt.
These are the commands you can run from your shell prompt that are built into the Minecraft script attached to this post. Swap mc_creative with mc_pvp as needed. If you run any of the backup or restart scripts while someone is logged in, they will get notices about the server shutting down 60 seconds before they get kicked.
/etc/init.d/mc_creative update - THIS WILL BREAK PLUGINS - DO IT MANUALLY
If you want people outside your network to be able to connect to your two Minecraft servers, you will have to forward ports 25565 and 25566 to your Ubuntu machine.
Reboot your Ubuntu server, and then try to play Minecraft. It should start up just fine.
This is the end of the first and hardest part of setting up your server. Next we will setup MySQL and create databases and users that Minecraft can access, and setup automated cron jobs for backups and log rotation.
Last edited by GrnEyedDvl; August 05, 2013 at 03:48 PM.
First of all I want to thank you for a great tutorial!
I am rather new to this and I need all the help I can get.
You wrote that there were some files attached to the post, but I can´t find any attached files.
Can you please attach them again?