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:
This will download the java installer, it shouldn't take more than a few seconds to do, once it's downloaded do:
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:
mkdir minecraft
Now that we've created the folder, move into that folder:
cd minecraft
You're now in the minecraft folder! Now we're going to create a folder for the first server:
mkdir one
then change into that folder:
cd one
You're now in the folder "one" inside of "minecraft", you can now download the minecraft server client:
Wait for it to download (should take <1 second), once done you'll need to unzip it:
unzip minecraft-server.zip
If all goes well then you'll have the contents of that folder in "one". run the following command:
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:
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:
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.
#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)
cd ../minecraft/one
Now do:
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":
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.
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 :smile.gif:
If there is some sort of security hole in the system, running as root means your entire system would be compromised as root can obviously do anything. Running as a user, only what the user has access to would be at risk, which ideally would only be local user files and nothing else.
I'm not sure that running as root makes your more susceptible to an attack, it just gives the attacker more power once "inside".
Rollback Post to RevisionRollBack
MineCraft Server Operator v0.3b
Votekick/voteban, remote access, automated backups, cross-platform and more.
Control your server.
I get errors when trying to start the server (both using nohup and screen) on Suse:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
I have server space with 1and1 (linux based) but do not have the ability to connect with SSH. Is there a way to get a minecraft server running on my server space?
Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction
Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction
:[
You're not running as root. Either sudo sh java.bin , or if you're not a sudoer, su -c 'sh java.bin' , for which you need a root account. Alternatively, you can login as root and run it, but I wouldn't recommend running Minecraft servers as root.
Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction
:[
You're not running as root. Either sudo sh java.bin , or if you're not a sudoer, su -c 'sh java.bin' , for which you need a root account. Alternatively, you can login as root and run it, but I wouldn't recommend running Minecraft servers as root.
okay, so I managed to get linux on a running old laptop of mine. Brand new install of ubuntu 9.04.
Little mistake. This isn't really a dedicated server, it's a remote server. Dedicated servers don't have to be remote, and remote servers don't have to be dedicated. Just a little thing that bugs me, otherwise good job :biggrin.gif:.
Please note that as of 2015 this post is over 6 years old and very likely to be out of date and unfollowable. Please refer to the wiki instead: http://minecraft.gamepedia.com/Tutorials/Setting_up_a_server
Original post continues below:
----
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:
Now that you're in the main directory, do:
This will download the java installer, it shouldn't take more than a few seconds to do, once it's downloaded do:
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:
Now that we've created the folder, move into that folder:
You're now in the minecraft folder! Now we're going to create a folder for the first server:
then change into that folder:
You're now in the folder "one" inside of "minecraft", you can now download the minecraft server client:
Wait for it to download (should take <1 second), once done you'll need to unzip it:
If all goes well then you'll have the contents of that folder in "one". run the following command:
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:
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:
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.
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)
Now do:
This will show you the externalurl for connecting with to private servers.
Uploading your own levels!
assuming you're in the folder "one":
then do
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.
This will now list all processes on your server, near the bottom you should see:
Then do:
where 4341 is the bold number.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 :smile.gif:
I get this when the port is blocked. I doubt this is the most secure method, in fact it's very insecure and brutish, but I just do:
then select "disable".
[quote name=Stiggs]Probably a dumb question, but where am I typing that? I put it in putty, but it gave me a 'command not found' error.
Strange.
Doing it like that, does the blue window not come up?
then try connecting again :biggrin.gif:
Personally I prefer "screen" instead of "nohup", because I can reopen the window agian.
How would running as root get them hacked?
(I'm interested to learn more, not being sarcastic :smile.gif:)
I'm not sure that running as root makes your more susceptible to an attack, it just gives the attacker more power once "inside".
Votekick/voteban, remote access, automated backups, cross-platform and more.
Control your server.
Yes. Start either an FTP server or a webserver. Tutorials abound online, or you can ask me or others in IRC.
sh java.bin
Then it gives me:
Do you agree to the above license terms? [yes or no]
yes
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP ([email protected]).
inflating: jre-6u14-linux-i586.rpm
error: can't create transaction lock on /var/lock/rpm/transaction
:[
You're not running as root. Either sudo sh java.bin , or if you're not a sudoer, su -c 'sh java.bin' , for which you need a root account. Alternatively, you can login as root and run it, but I wouldn't recommend running Minecraft servers as root.
okay, so I managed to get linux on a running old laptop of mine. Brand new install of ubuntu 9.04.
I try and run the java.bin and it gives me
java.bin: 438: rpm: not found
is down.