How To Install Minecraft Server on Debian 12
In this tutorial, we will show you how to install Minecraft Server on Debian 12. Setting up a Minecraft server on Debian 12 offers a perfect blend of stability, performance, and security for your gaming experience. Whether you’re creating a private server for friends or establishing a public gaming community, Debian 12’s robust architecture provides an excellent foundation. This comprehensive guide walks you through each step of the installation process, from preparing your system to optimizing server performance and implementing essential maintenance strategies.
Prerequisites and System Requirements
Before diving into the installation process, ensure your system meets the necessary requirements for a smooth Minecraft server experience.
Hardware Requirements
Running a Minecraft server demands adequate hardware resources to ensure optimal performance. Your server should have at least 2 CPU cores for smooth operation. Memory requirements start at 4GB RAM minimum, though 8GB or more is strongly recommended for larger player counts or complex worlds. Storage needs include at least 10GB of free space for the server software, world data, and future expansions. Finally, a stable internet connection with reasonable bandwidth is crucial for multiplayer functionality.
Software Prerequisites
A fresh Debian 12 installation serves as the foundation for your Minecraft server. You’ll need a user account with sudo privileges to execute administrative commands. Basic familiarity with Linux commands will be helpful, though this guide provides detailed instructions for each step.
Pre-Installation Steps
Start by updating your system packages to ensure you have the latest security patches and improvements:
sudo apt update
sudo apt upgrade -y
Next, install essential utilities that will assist with server management:
sudo apt install wget screen nano -y
These tools will help you download files, manage server sessions, and edit configuration files throughout the setup process.
Understanding Java Requirements
Minecraft server software runs on Java, making it essential to install the correct version for compatibility with your desired Minecraft version.
Minecraft Version Compatibility
Different Minecraft versions require specific Java versions. For Minecraft 1.20.4 and earlier versions, Java 17 (included in Debian 12) is sufficient. However, Minecraft 1.20.5 and newer versions require Java 21, which needs special installation as it’s not included in the default Debian 12 repositories.
Installing Java 17
For Minecraft versions 1.20.4 and earlier, install the default Java Runtime Environment:
sudo apt update
sudo apt install default-jre -y
Verify the installation by checking the Java version:
java -version
The output should confirm Java 17 is installed on your system.
Installing Java 21 for Newer Minecraft Versions
For Minecraft 1.20.5 and newer, you’ll need Java 21. The recommended approach is using the Adoptium repository:
sudo apt install -y wget apt-transport-https
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add -
echo "deb https://packages.adoptium.net/artifactory/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt update
sudo apt install temurin-21-jdk -y
Alternatively, you can install Amazon Corretto as another option:
wget https://corretto.aws/downloads/latest/amazon-corretto-21-x64-linux-jdk.deb
sudo dpkg -i amazon-corretto-21-x64-linux-jdk.deb
sudo apt-get install -f
Managing Multiple Java Installations
If you need to support multiple Minecraft versions, you may need to switch between Java versions. Use the update-alternatives
command to manage this:
sudo update-alternatives --config java
This displays all installed Java versions, allowing you to select which one to use as the default.
Creating a Minecraft User
Running your Minecraft server as a dedicated user improves security and organization.
Security Benefits
Running the server as a non-root user is crucial for security. This approach isolates the Minecraft server process from system-critical functions, preventing potential security breaches from affecting your entire system.
User Creation Process
Create a dedicated Minecraft user with the following commands:
sudo adduser minecraft
Follow the prompts to set a password and user information. Next, give this user the necessary permissions:
sudo mkdir -p /opt/minecraft
sudo chown -R minecraft:minecraft /opt/minecraft
User Management
To switch to the Minecraft user, use:
su - minecraft
Or when executing commands:
sudo -u minecraft command
This ensures all server operations run under the minecraft user context, maintaining proper security boundaries.
Downloading the Minecraft Server
Selecting the right server software is crucial for your gaming experience.
Server Software Options
Several Minecraft server implementations are available:
- Official Minecraft Server (Vanilla) – The standard server provided by Mojang, offering the pure Minecraft experience.
- Spigot – A modified server with improved performance and plugin support.
- Paper – A fork of Spigot with additional optimizations and features.
- Forge – Supports mods for enhanced gameplay options.
Downloading the Official Server
Switch to the minecraft user and navigate to the server directory:
su - minecraft
cd /opt/minecraft
Download the latest server JAR file from the official website using wget:
wget https://launcher.mojang.com/v1/objects/3737db93722a9e39eeada7c27e7aca28b144ffa7/server.jar -O minecraft_server.jar
Replace the URL with the current version from the Minecraft website. Verify the download completed successfully by checking the file size:
ls -lh minecraft_server.jar
Building a Spigot Server (Alternative)
For a more optimizable server with plugin support, you can build Spigot:
mkdir -p /opt/minecraft/buildtools
cd /opt/minecraft/buildtools
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev latest
This process downloads and compiles the latest Spigot server. Once complete, move the resulting JAR file to your server directory.
Version Selection Considerations
When selecting a Minecraft version, ensure compatibility between server and client versions. Newer versions offer more features but might require more resources. Older versions may be more stable and have better plugin support. Consider your specific needs when making this decision.
Initial Server Setup
After downloading the server software, you’ll need to perform initial configuration steps.
First-Time Server Execution
Run the server for the first time to generate necessary configuration files:
cd /opt/minecraft
java -Xmx1024M -jar minecraft_server.jar nogui
The server will start and then immediately stop, creating several files in the process. This is normal behavior for the first run.
Accepting the EULA
Before the server can fully operate, you must accept the Minecraft End User License Agreement (EULA). Edit the eula.txt file created during the first run:
nano eula.txt
Change eula=false
to eula=true
, save the file, and exit the editor. This indicates your acceptance of Mojang’s terms for running a Minecraft server.
Understanding Server Files
The initial run generates several important files:
server.properties
: Main configuration file for server settingseula.txt
: End User License Agreement acceptanceserver.jar
: The actual server programworld/
: Directory containing world data (generated after first full start)logs/
: Server log files for troubleshooting
File Permissions
Ensure all files have the correct ownership:
sudo chown -R minecraft:minecraft /opt/minecraft
This prevents permission issues during server operation.
Server Configuration
Proper configuration is essential for a well-functioning Minecraft server.
Essential server.properties Settings
Edit the server.properties file to configure core server behavior:
nano server.properties
Key settings to consider include:
server-ip
: Leave blank to bind to all network interfacesserver-port
: Default is 25565, change if neededgamemode
: survival, creative, adventure, or spectatordifficulty
: peaceful, easy, normal, or hardmax-players
: Maximum number of concurrent playerswhite-list
: Set to true to restrict access to specified playersspawn-protection
: Radius around spawn where building is restricted
Performance-Related Options
These settings significantly impact server performance:
view-distance
: Distance in chunks players can see (lower for better performance)simulation-distance
: Distance for entity processing (affects mob behavior)max-tick-time
: Maximum milliseconds per tick before considering server overloadednetwork-compression-threshold
: Data compression settings
Security Configurations
Enhance server security with these options:
online-mode
: Set to true to verify player authenticity (recommended)enforce-secure-profile
: Requires cryptographically signed profilesprevent-proxy-connections
: Blocks VPN and proxy connectionswhite-list
: Enable to restrict server access to specified players
World Generation Settings
Customize your world environment:
level-seed
: Specific seed for world generation (leave blank for random)level-type
: DEFAULT, FLAT, LARGEBIOMES, AMPLIFIED, etc.generate-structures
: Controls generation of villages, strongholds, etc.
Message and Naming
Create a welcoming environment:
motd
: Message of the Day displayed in the server listserver-name
: Name for your serverresource-pack
: URL to a custom resource pack
After making changes, save the file and restart your server to apply the new settings.
Creating Management Scripts
Well-designed scripts simplify server management and enhance reliability.
Start Script Creation
Create a start script with optimized Java parameters:
nano /opt/minecraft/start.sh
Add the following content:
#!/bin/bash
cd /opt/minecraft
java -Xms2G -Xmx4G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -jar minecraft_server.jar nogui
Adjust memory allocation (-Xms and -Xmx) based on your server’s available RAM. Make the script executable:
chmod +x /opt/minecraft/start.sh
Stop Script Implementation
Create a script for safely stopping the server:
nano /opt/minecraft/stop.sh
Add the following content:
#!/bin/bash
screen -S minecraft -X stuff "say Server shutting down in 10 seconds...
"
sleep 5
screen -S minecraft -X stuff "say Server shutting down in 5 seconds...
"
sleep 5
screen -S minecraft -X stuff "stop
"
Make it executable:
chmod +x /opt/minecraft/stop.sh
Backup Script Development
Regular backups prevent data loss. Create a backup script:
nano /opt/minecraft/backup.sh
Add the following content:
#!/bin/bash
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/opt/minecraft/backups"
WORLD_DIR="/opt/minecraft/world"
# Create backup directory if it doesn't exist
mkdir -p $BACKUP_DIR
# Notify players of backup
screen -S minecraft -X stuff "say Starting server backup, expect some lag...
"
# Create backup
tar -czf $BACKUP_DIR/world_$TIMESTAMP.tar.gz $WORLD_DIR
# Cleanup old backups (keep last 7)
ls -tr $BACKUP_DIR/world_*.tar.gz | head -n -7 | xargs -r rm
# Notify completion
screen -S minecraft -X stuff "say Backup complete!
"
Make it executable:
chmod +x /opt/minecraft/backup.sh
Configure a cron job to run automatic backups:
sudo crontab -e
Add a line to run backups daily at 3 AM:
0 3 * * * /opt/minecraft/backup.sh
Running the Server with Screen
The Screen utility allows the server to run in the background, even after you disconnect from SSH.
Screen Utility Installation
If not already installed:
sudo apt install screen -y
Starting a Screen Session
Launch a named screen session for your Minecraft server:
screen -S minecraft -L -Logfile /opt/minecraft/console.log
Inside this session, start your server using the script created earlier:
/opt/minecraft/start.sh
Screen Management Commands
Essential screen commands to know:
- Detach from session: Press
Ctrl+A
followed byD
- Reattach to session:
screen -r minecraft
- List active sessions:
screen -ls
- Terminate a session:
screen -X -S minecraft quit
Troubleshooting Screen Issues
If you can’t reattach to a screen session, it might be:
- Already attached elsewhere: Use
screen -D -r minecraft
to detach and reattach - Not running: Check with
screen -ls
and restart if needed - Permission issues: Ensure you’re using the same user that started the screen
Firewall Configuration
Properly configuring your firewall ensures players can connect to your server.
Port Requirements
Minecraft uses TCP port 25565 by default. You’ll need to allow incoming traffic on this port through your firewall.
UFW Configuration
For systems using UFW (Uncomplicated Firewall):
sudo apt install ufw -y
sudo ufw allow ssh
sudo ufw allow 25565/tcp
sudo ufw enable
Verify the configuration:
sudo ufw status
Testing Connectivity
Test your server connectivity:
- From another computer on your local network, use:
telnet your_server_ip 25565
- From outside your network, ensure port forwarding is configured on your router
- Use online port checking tools like canyouseeme.org
If connection issues persist, check for typos in IP addresses and ensure your router is properly forwarding port 25565 to your server.
Setting Up Automatic Startup
Configure your Minecraft server to start automatically when your system boots.
Systemd Service Creation
Create a systemd service file:
sudo nano /etc/systemd/system/minecraft.service
Add the following content:
[Unit]
Description=Minecraft Server
After=network.target
[Service]
User=minecraft
Group=minecraft
WorkingDirectory=/opt/minecraft
Type=simple
ExecStart=/usr/bin/screen -DmS minecraft /opt/minecraft/start.sh
ExecStop=/opt/minecraft/stop.sh
Restart=on-failure
RestartSec=60s
[Install]
WantedBy=multi-user.target
Enabling Automatic Startup
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable minecraft.service
sudo systemctl start minecraft.service
Service Management
Common service management commands:
sudo systemctl status minecraft.service
sudo systemctl start minecraft.service
sudo systemctl stop minecraft.service
sudo systemctl restart minecraft.service
Troubleshooting Startup Issues
If the service fails to start:
- Check logs with
sudo journalctl -u minecraft.service
- Verify file permissions on all scripts
- Ensure the minecraft user has write access to all required directories
- Test the start script manually to isolate issues
Optimizing Server Performance
Fine-tuning your server improves player experience and reduces resource usage.
Java Optimization Flags
The start script includes several optimization flags, but you can further customize:
- G1GC garbage collector optimizations reduce lag spikes during garbage collection
- ParallelRefProcEnabled improves multithreaded performance
- MaxGCPauseMillis limits garbage collection pauses
- AlwaysPreTouch allocates memory at startup for better performance later
Server.properties Optimization
Key settings for performance:
- Reduce view-distance to 8-10 for better performance
- Set max-players appropriate to your hardware
- Configure simulation-distance slightly lower than view-distance
- Adjust entity-broadcast-range-percentage (lower values reduce network load)
Resource Allocation
Balance resource allocation for optimal performance:
- Allocate 60-70% of available system RAM to Minecraft (but not more than 8GB for most servers)
- Leave CPU resources for OS operations
- Consider using a separate disk for world files if available
Monitoring Performance
Install monitoring tools to track server health:
sudo apt install htop iotop -y
Use these tools to identify resource bottlenecks and adjust configurations accordingly.
Congratulations! You have successfully installed Minecraft. Thanks for using this tutorial for installing the Minecraft server on your Debian 12 “Bookworm” system. For additional help or useful information, we recommend you check the official Minecraft website.