How to host a dedicated server for Build 42
There are 2 ways to host a server on Build 42, one method in case you are going to do it on your own computer and another if you are using a VPS for example.
Hosting on own computer
If you are going to host on you own computer, search on your library for "Project Zomboid Dedicated Server", then right click on it and go to Properties > Game Versions & Betas and select "unstable". Check the image to see how it would look like.
After doing so, DO NOT start the server through Steam, if you did so make a file integrity check. You must start the serer through your file manager, directly by the files named "StartServer". You will notice there are 3 of them, the one finishing with 32 is for 32bit systems, the 64 for 64bit system.
By default, the server will use up to 16gb of memory, if you want to change it you need to run the Xms and Xmx code, the following is an example of code to tell java to use up to 6gb of RAM for the server:
".\jre64\bin\java.exe" -Djava.awt.headless=true -Dzomboid.steam=1 -Dzomboid.znetlog=1 -XX:+UseZGC -XX:-CreateCoredumpOnCrash -XX:-OmitStackTraceInFastThrow -Xms6g -Xmx6g -Djava.library.path=natives/;natives/win64/;. -cp %PZ_CLASSPATH% zombie.network.GameServer -statistic 0
Hosting on a VPS
As I don't have knowledge on how to use a VPS with Windows and most of them uses Linux (specially Ubuntu Server) anyway, this section will only cover steamcmd using Linux.
First you need to have steamcmd installed, if you don't do the following:
sudo add-apt-repository multiverse;
sudo dpkg --add-architecture i386;
sudo apt update
sudo apt install steamcmd
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install steamcmd -y
Ideally you won't run ANY server using root as it brings security risks, if you already have a second user that does not have root privileges, login with it now, if you don't have one create one and login to it:
sudo adduser new-user-name
sudo -u new-user-name -i
I will create the server directory to download the server in the new user's home, if you want to install it somewhere else just change the path:
mkdir pzserver
cd pzserver
Now copy the following code, it will create a file with all the commands for steamcmd to download the server files (copy all the lines at once):
cat >$HOME/update_zomboid.txt <<'EOL'
// update_zomboid.txt
//
@ShutdownOnFailedCommand 1 //set to 0 if updating multiple servers at once
@NoPromptForPassword 1
force_install_dir /home/new-user-name/pzserver/
//for servers which don't need a login
login anonymous
app_update 380870 -beta unstable validate
quit
EOL
Now you need to execute the steamcmd to download the files, it will also be used to update the server:
steamcmd +runscript $HOME/update_zomboid.txtsteamcmd +runscript $HOME/update_zomboid.txt
Now you need to forward the necessary ports:
sudo ufw allow 16261/udp
sudo ufw allow 16262/udp
sudo ufw reload
To start the server you need to run the start-server.sh file created in the pzserver folder:
bash start-server.sh -server-name MyServer
Withh this your server should be ready to go.
1 Comment