How to Set Up a Minecraft Server on CentOS 7: Java, Firewall, systemd, and Backups

How to set up a Minecraft server on CentOS 7

Setting up a Minecraft server on CentOS 7 is still a practical choice for users who want full control over server versioning, plugins, mods, world files, backups, memory allocation, and startup behavior. Unlike one-click game hosting panels, a self-managed installation gives you a transparent environment: you know where the files are stored, how Java is launched, which port is open, how the service starts after reboot, and how backups are handled. That transparency is one of the biggest advantages when you want a server that is maintainable and predictable over time.

The overall process is straightforward: prepare a CentOS 7 system, install Java, create a dedicated service user, download the Minecraft server .jar file, configure a systemd service, and open the required firewall port. In most cases this runs on Virtual Servers, because a VPS gives you root access and flexible resource control. For heavier usage, larger worlds, or modded environments, Dedicated Servers may be more appropriate. For keeping world backups outside the main host, Cloud Storage is also useful.

Before installing anything else, confirm which Java version your chosen Minecraft build requires. Older versions often work with Java 8, while newer releases frequently require Java 17. This is important because many failed Minecraft installations are actually Java compatibility problems. Getting Java right first will save time later.

1) Prepare the system and create a dedicated user

You should not run the Minecraft process as root. A better and safer pattern is to create a dedicated user called minecraft and keep all server files under that account. This reduces unnecessary privileges, keeps the filesystem cleaner, and makes future maintenance easier. It also makes backup and migration tasks more predictable, because everything lives in a single controlled directory tree.

sudo yum update -y
sudo yum install -y wget curl nano tar unzip screen

sudo useradd -r -m -U -d /opt/minecraft -s /bin/bash minecraft
sudo mkdir -p /opt/minecraft/server
sudo chown -R minecraft:minecraft /opt/minecraft

Using a structure like /opt/minecraft/server is a good long-term habit. If you later add another test instance, a staging server, or a different Minecraft version, you can keep the setup organized instead of scattering files across the system.

2) Install Java and verify the runtime

Minecraft depends on Java, and the required version depends on the exact server build. On CentOS 7, OpenJDK packages are usually available in the repository. Install the version you actually need instead of assuming that any Java package will work. After installation, always check the active version with java -version.

sudo yum install -y java-17-openjdk java-17-openjdk-headless
java -version

If your chosen server build requires Java 8 instead, install the corresponding java-1.8.0-openjdk packages. The version check matters because some systems end up with multiple Java installations, and Minecraft may attempt to run against the wrong runtime if you do not confirm it explicitly.

3) Download the server JAR and perform the first startup

Switch to the minecraft user, move into the working directory, and download the server JAR. This guide keeps the download URL abstract because the correct source depends on whether you are running vanilla Minecraft, Paper, Spigot, or another implementation.

sudo su - minecraft
cd /opt/minecraft/server

wget -O server.jar YOUR_SERVER_JAR_URL
ls -lh

Now launch the server once so it can generate its initial files, including eula.txt and server.properties. Use a moderate heap size for the first run. There is no need to allocate all available memory immediately. The operating system and file cache still need RAM, and oversized Java heaps are not automatically better.

java -Xms1G -Xmx2G -jar server.jar nogui

On the first run the server will typically stop because the EULA has not been accepted. Edit eula.txt and change eula=false to eula=true. That is required before the server can fully start.

nano eula.txt
# change:
eula=false

# to:
eula=true

4) Configure server.properties

The main game settings live in server.properties. This file controls the server port, maximum player count, MOTD, online mode, whitelist behavior, difficulty, view distance, and many other options. It is worth spending a few extra minutes here, because these values affect both player experience and server performance.

For a small private server, start conservatively. A modest max-players value, whitelist enabled, and moderate view-distance settings are usually better than aggressive defaults. It is easier to scale up after observing real player behavior than to begin with an overloaded configuration.

nano server.properties
motd=CloudHosting Minecraft Server
server-port=25565
max-players=10
online-mode=true
white-list=true
view-distance=8
simulation-distance=6
difficulty=normal
spawn-protection=0

If the server is intended for friends only, whitelist is strongly recommended. If you plan to make the server public later, you can adjust those settings once the base installation is confirmed stable.

5) Create a systemd service for automatic startup

For long-term use, do not rely only on manual startup or a screen session. A systemd service gives you automatic startup after reboot, easier status checks, and cleaner restart behavior. It also makes the environment easier to reproduce if you ever migrate to another server.

sudo nano /etc/systemd/system/minecraft.service
[Unit]
Description=Minecraft Server
After=network.target

[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft/server
ExecStart=/usr/bin/java -Xms1G -Xmx2G -jar /opt/minecraft/server/server.jar nogui
ExecStop=/bin/kill -SIGINT $MAINPID
Restart=on-failure
RestartSec=20
Nice=1
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
PrivateTmp=true

[Install]
WantedBy=multi-user.target

After saving the unit file, reload systemd, enable the service, and start it. The service status is a fast way to confirm whether the Java path, JAR location, and working directory are correct.

sudo systemctl daemon-reload
sudo systemctl enable minecraft
sudo systemctl start minecraft
sudo systemctl status minecraft

6) Open the firewall and test connectivity

Minecraft Java Edition uses TCP port 25565 by default. If the process starts but clients cannot connect, the most common cause is firewall configuration—either firewalld inside CentOS or provider-level network filtering. Open the port and verify that the process is actually listening.

sudo firewall-cmd --permanent --add-port=25565/tcp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports
ss -lntp | grep 25565

After that, connect with a Minecraft client using the server IP address. If you want to use a domain name, create an A record pointing to the server IP. For private environments, keeping online-mode=true and whitelist enabled is a good default because it reduces accidental exposure to the public internet.

Performance, security, and backups

Minecraft performance is not only about RAM. CPU single-thread performance, disk speed, world size, simulation distance, and plugin or mod behavior all matter. Allocating a very large Java heap does not automatically improve performance and can sometimes make garbage collection less efficient. The best approach is to start with reasonable settings and adjust based on actual usage.

From a security perspective, run the server under its own user, keep unnecessary ports closed, and update Java regularly. If you use plugins or modded server builds, download them only from trusted sources. Unverified extensions can create both stability and security problems.

Backups are critical because the world files are the most valuable part of the installation. Reinstalling the server software is easy; rebuilding a lost world is not. A simple backup approach is to archive the server directory periodically and store the archive elsewhere.

tar -czf /tmp/minecraft-backup-$(date +%F).tar.gz /opt/minecraft/server

If the server is intended to live for months rather than days, document the Minecraft version, Java version, systemd unit, firewall settings, and backup procedure. That documentation becomes very useful during updates, migrations, and troubleshooting. A reliable Minecraft server is not just one that starts successfully once; it is one that can be maintained, recovered, and expanded with confidence.