Total Pageviews

Sunday 15 January 2012

Setting up a Minecraft server on centos vps

Setting up a Minecraft server can be pretty difficult if you don't know what you're doing. This tutorial is to simplify running it on CentOS 5.

We'll need to following:

- Dedicated Server / Xen based VPS
- CentOS 5.x 32bit/64bit
- 1GB of RAM or more
- Latest Java JDK
- Minecraft Server

Let's start with getting a Xen VPS, grab one from PhotonVPS. You'll need a Xen one, so I'll recommend a WARP2 or higher.

Now, let's get started by installing Java-JDK:

yum install java-1.6.0-openjdk

Now, let's check if Java was installed:

which java

It should display the following if it was properly installed:

/usr/bin/java

We're done with that now, let's create a directory for Minecraft then install it:

1. Make sure we're in the root directory still:

cd

2. Now let's create the directory:

mkdir Minecraft

3. Enter the directory:

cd Minecraft

4. Time to get Minecraft:

wget http://minecraft.net/download/minecraft_server.jar

5. We'll need to make sure Minecraft as all the correct permissions:

chmod +x minecraft_server.jar

Minecraft is now installed!

From here we'll need to install "screen" to keep the Minecraft server running after we close the SSH session.

Install screen:

yum install screen

Now, we'll use the screen and run Minecraft from there.

screen

Starting up Minecraft now:

java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui

(*1024 value can be changed depending on how much RAM your VPS has)
Ex. 512MB VPS - java -Xmx512M -Xms512M -jar minecraft_server.jar nogui
Ex. 2048MB VPS - java -Xmx2048M -Xms2048M -jar minecraft_server.jar nogui

To get back to the normal screen now you'll have to do the following:

Control + a + d

To get back to the screen where Minecraft is running:

screen -r

That's it for getting Minecraft up and running on CentOS!

If you need a VPS, check out PhotonVPS Xen based VPS and use coupon code "MINECRAFTVPS" to receive 10% recurring on all monthly plans.
from
http://www.photonvps.com/minecraft.html
--------------------------------------
Set up a Minecraft SMP server on Ubuntu

Automatically installs Java, creates a minecraft user, pulls in the latest minecraft_server.jar, and writes a script to automatically start the server. Read the comments in the script for more information.

Following script works on the following OS: Ubuntu 10.04 LTS|Ubuntu 10.10|Ubuntu 9.10

You can download it here or see below for the details.

#!/bin/bash
#
# Minecraft Stackscript
# Prepares the system, installs Java, installs Minecraft, and starts the server.
# By Jed Smith <jed@jedsmith.org>
#
# <udf name="mcopname" label="Admin Nickname" example="Nickname to give initial operator status">
# <udf name="mclevelname" label="Level Name" default="world" example="Name for the level">
# <udf name="mconline" label="Online Mode" default="yes" oneOf="yes,no" example="Whether the server will verify usernames with minecraft.net">
# <udf name="mcmonsters" label="Spawn Monsters" default="yes" oneOf="yes,no">
# <udf name="mcmaxplayers" label="Maximum Players" default="20">
#
# Once this script is completed, you can start the Minecraft server by typing the following:
#
# # su - minecraft -s /opt/minecraft/run.sh
#
# This StackScript installs screen as well, so you can assign a password to the minecraft user,
# log in as the minecraft user, and run minecraft in a screen (if you so desire).
#
# Don't run minecraft as root!
#

# which distro are we on?
distro=`grep DISTRIB_CODENAME /etc/lsb-release | cut -d'=' -f 2`

# add source for java
cat >>/etc/apt/sources.list <<EOF

# for java, added by minecraft stackscript
deb http://archive.canonical.com/ubuntu $distro partner
deb-src http://archive.canonical.com/ubuntu $distro partner
EOF

# update and install packages
apt-get -y update
apt-get -y upgrade

# accept the sun-dlj-v1-1 license
for j in jdk jre; do
echo "sun-java6-$j shared/accepted-sun-dlj-v1-1 select true" | /usr/bin/debconf-set-selections
done

# install java
apt-get -y install sun-java6-jre screen

# add the minecraft user
adduser --system --group --disabled-login --disabled-password --home /opt/minecraft minecraft
cd /opt/minecraft

# find where to get minecraft (please don't change this, Notch)
version=`wget -q -O- http://www.minecraft.net/download.jsp | grep "download/minecraft_server.jar" | cut -d'"' -f 2`
wget -O minecraft_server.jar "http://www.minecraft.net/$version"

# convert configuration variables
[ "$MCONLINE" == "yes" ] && MCONLINE=true
[ "$MCONLINE" == "true" ] || MCONLINE=false
[ "$MCMONSTERS" == "yes" ] && MCMONSTERS=true
[ "$MCMONSTERS" == "true" ] || MCMONSTERS=false

# write the configuration
cat >server.properties <<EOF
# Minecraft server properties
# Created by Minecraft StackScript `date`
online-mode=$MCONLINE
monsters=$MCMONSTERS
server-ip=
server-port=25565
max-players=$MCMAXPLAYERS
level-name=$MCLEVELNAME
EOF

# initial op user
echo $MCOPNAME >ops.txt
touch banned-players.txt
touch banned-ips.txt

# write the run script
cat >run.sh <<EOF
#!/bin/sh
java -Xmx1024M -Xms1024M -jar /opt/minecraft/minecraft_server.jar nogui
EOF

# clean up
chown minecraft:minecraft *
chmod a+x run.sh

# do a motd too
cat >/etc/motd.tail <<EOF

This server has been deployed from Jed Smith's Minecraft StackScript. To start
Minecraft, run the following as root:

# su - minecraft -s /opt/minecraft/run.sh

screen is also installed if you prefer to run Minecraft in a screen. It is a
very bad idea to run the Minecraft server as root; although there are no
currently-known vulnerabilities, you're better off insulating your server.

All files related to the server are in /opt/minecraft.
EOF

Taken from: http://www.linode.com/stackscripts/view/?StackScriptID=232

No comments:

Post a Comment