Setup Paper on CentOS 7
Introduction
Paper is a high-performance fork of Spigot that aims to fix gameplay and mechanics inconsistencies. Paper has many unique features and changes, including many performance improvements not found in Spigot. This guide explains how to set up Paper on a Vultr CentOS 7 Server. It is recommended to run all commands as a non-root user with sudo
privileges.
1. Install Prerequisites
- Deploy a Vultr CentOS 7 cloud server instance.
- Create a sudo user.
- Update the CentOS server.
Install the required prerequisite software.
$ sudo cat <<'EOF' > /etc/yum.repos.d/adoptopenjdk.repo
[AdoptOpenJDK]
name=AdoptOpenJDK
baseurl=http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
EOF
$ sudo yum install adoptopenjdk-11-hotspot -y
$ sudo yum install epel-release -y
$ sudo yum install jq -y
2. Create a Swapfile
Create a swap file. The example allocates a 1 GB file, set this value according to your needs.
$ sudo fallocate -l 1G /swapfile
Set the permissions of the swap file.
$ sudo chmod 600 /swapfile
Allocate the swap space.
$ sudo mkswap /swapfile
Turn on swap.
$ sudo swapon /swapfile
Make your swap file permanent by modifying the fstab
file.
$ sudo nano /etc/fstab
Add this line to the bottom of the file.
/swapfile none swap sw 0 0
3. Install Paper
Ensure you are in the home
directory of the user you plan to use for Paper.
$ cd ~
Create a folder for Paper and download the latest build. This example downloads Paper version 1.16.5. If you need a different version, replace 1.16.5
with the version you want to download.
$ mkdir paper
$ cd paper
$ LATEST_BUILD=$(curl -X GET "https://papermc.io/api/v2/projects/paper/versions/1.16.5" -H "accept: application/json" | jq '.builds[-1]')
$ curl -o paperclip.jar -X GET "https://papermc.io/api/v2/projects/paper/versions/1.16.5/builds/${LATEST_BUILD}/downloads/paper-1.16.5-${LATEST_BUILD}.jar" -H "accept: application/java-archive" -JO
If you want an older build, look up the available build numbers.
$ curl -X GET "https://papermc.io/api/v2/projects/paper/versions/1.16.5" -H "accept: application/json"
Replace [BUILD_ID] in the following command with the desired build.
$ curl -o paperclip.jar -X GET "https://papermc.io/api/v2/projects/paper/versions/1.16.5/builds/[BUILD_ID]/downloads/paper-1.16.5-[BUILD_ID].jar" -H "accept: application/java-archive" -JO
4. Start the Server
Create a startup script for your server.
$ nano start.sh
Paste the following into start.sh
. The 4G
parameters in -Xms4G -Xmx4G
configure Java for 4 GB of RAM. Change this to the amount of RAM you want to allocate for Paper. The operating system requires available RAM as well, please don't assign all available RAM to Paper. For example, if the VPS has 8 GB RAM, you might consider setting -Xms7G -Xmx7G
.
#!/bin/sh
while true
do
java -Xms4G -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 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar paperclip.jar nogui
echo "restarting in 10"
sleep 10
done
Make start.sh
executable.
$ chmod +x start.sh
Start your server.
$ ./start.sh
Java downloads Paper. The first time it loads, it prompts you to accept the EULA and fails to load. The script then loops, and you need to type Ctrl + C to exit the script at this point.
Edit eula.txt
.
$ nano eula.txt
Change eula=
from false to true
. Save and exit the file.
Start your server again.
$ ./start.sh
Optional: Run the server in the background
Install screen.
$ sudo yum install screen -y
Open an instance of screen.
$ screen -S "paper"
Start your server script.
$ cd ~/paper
$ ./start.sh
Configure your server's settings and install plugins.
Troubleshooting
If paperclip.jar doesn't run, you need more RAM on your server or a larger swap file.