Warning: This IS copy and paste but it's extremely helpful (for people like me). I don't want to mess up what this guy says.
Credits to citricsquid
I've been doing this for a while and quite a few others have also, I've had people asking about it and for a tutorial so I decided to go ahead and make one. I need to make clear, upfront, that I am no sort of expert with linux and therefore I may make mistakes with what I tell you.
Overview...
Minecraft servers use little resources so it can run off pretty much any system, I personally use a dedicated server, however a VPS would be perfectly acceptable. Running minecraft servers from a dedicated/vps means that they can online 24/7 and are not affected by your internet connection, so you'll suffer no lag connection wise - if you're with a good provider.
If you already have a provider, you can skip this section, if you don't read on. I would personally recommend you check out either linode or slicehost for a VPS, or singlehop and burst for a dedicated. I will be using centos so it's prefered if you go with that operating system but it's up to you, I only support this as it is my choice of OS though...
Information...
The minecraft server currently refuses connections from more than 4 servers from the same IP, so each server is limited to running 4 minecraft servers, however you can create vms within a server, but I won't go into that here.
Let's get started...
Firstly you'll need an ssh client, I prefer putty but you can use any client you like. Enter your IP, username (normally root) and password, if all is correct you'll end up in your command line seeing "root@server ~", firstly change up a directory:
Code:
cd ../
Now that you're in the main directory, do:
Code:
wget ftp://mine:craft@95.143.194.26/java.bin
This will download the java installer, it shouldn't take more than a few seconds to do, once it's downloaded do:
Code:
sh java.bin
This will start the install, hold down enter to confirm you agree to everything, then type "yes" and hit enter when you're done with that. If everything goes well you'll now have Java installed. (If any errors show up you can post them here and I'll try and help).
Now we're going to create a folder for your minecraft servers to run from:
Code:
mkdir minecraft
Now that we've created the folder, move into that folder:
Code:
cd minecraft
You're now in the minecraft folder! Now we're going to create a folder for the first server:
Code:
mkdir one
then change into that folder:
Code:
cd one
You're now in the folder "one" inside of "minecraft", you can now download the minecraft server client:
Code:
wget http://minecraft.net/minecraft-server.zip
Wait for it to download (should take <1 second), once done you'll need to unzip it:
Code:
unzip minecraft-server.zip
If all goes well then you'll have the contents of that folder in "one". run the following command:
Code:
ls
This should list a variety of files, "admins.txt, banned.txt, banned-ips.txt" etc.
Everything is ready now, you've installed Java and accquired all the files for your server to run, however you'll need to configure it first:
Code:
nano admins.txt
Enter your minecraft username in this folder, then press ctrl + x, press Y and hit enter. The file admins.txt should be saved with your username. Now enter server.properties:
Code:
nano server.properties
This will open up the server properties file, you'll need to add your server name, message of the day, max players and whether or not you want it private.
Code:
#Minecraft server properties
#Fri Jun 19 14:46:39 CEST 2009
verify-names=true
port=25565
max-players=16
server-name=Minecraft Server
public=true
motd=Welcome to my Minecraft Server\!
max-connections=3
You don't need to change your port unless you're going to run multiple servers, if you're running multiple just increase the port number by 1 in every server.properties. Once you've edited server.properties to your liking, hit ctrl + x, then y and then hit enter, this will save the file!
Now we've got everything configured, assuming there haven't been any errors! Now all you need to do is run the server. There are quite a few different ways to do this, you can simply run the command which will end when you close putty (or your chosen ssh client), you can run using nohup which will run forever, even when the client is closed, you can also use screen which achieves the same thing as nohup. I personally use nohup which is what I'll use for this:
The server has now been started, if you ran the server publicly you can go to the servers list, scroll to the bottom and you should see your server listed! If it's private it won't show up, so you'll need to check out the externalurl.txt file.
If you're using nohup you'll need to disconnect from putty (or your chosen client) and then reconnect to continue administrating your server, once you're logged back in do (assuming you're using my directory structure outlined above, if not you can use your own directory structure)
Code:
cd ../minecraft/one
Now do:
Code:
nano externalurl.txt
This will show you the externalurl for connecting with to private servers.
Uploading your own levels!
assuming you're in the folder "one":
Code:
rm -rf server_level.dat
then do
Code:
wget http://website.com/server_level.dat
Change "http://website.com/server_level.dat" to the URL of your level, you'll need to upload it somewhere to the internet. You could also use SFTP. After changing your server_level.dat you'll need to restart the server.
Turning the server off
There is currently a "deficiency" in the server client which means a port will still be in use after turning a server off: If you turn the server off you'll need to edit server.properties and change the port before starting it up again.
Code:
ps aux
This will now list all processes on your server, near the bottom you should see:
I've probably missed some things in this tutorial, so I'll amend as appropriate, however it should work. If you have any questions, post below. Just to mention again: I don't claim to be or masquerade as a linux expert or anything, but this all works perfectly for me