Setting up a Multiplayer Server/en: Difference between revisions

From Vintage Story Wiki
Updating to match new version of source page
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 2: Line 2:
== Basic Setup ==
== Basic Setup ==


===Ad-hoc Server===
=== Ad-hoc Server ===
If you want a temporary multiplayer experience it is enough to open a single player world, then click on "Open to Lan" in the escape menu. This will allow players in your local network to join.
If you want a temporary multiplayer experience it is enough to open a single player world, then click on "Open to Lan" in the escape menu. This will allow players in your local network to join.
If you want to allow players outside of your local network to join, you can then also click "Open to Internet" which will attempt to set up an external connection to join your server from the internet. This is done by a technique called UPnP and has to be enabled on your internet router, which it often is by default. In short, we estimate there's about a 60% success chance that 'Open to Internet' works instantly without issues. If it doesn't you would need to set up a so called "port forwarding" on your internet router, which can be tricky and frustrating at times, unfortunately. You would need to forward TCP Port 42420 to your computer in that case. (Google 'Port forwarding' with the name or model of your internet router to find help.)
If you want to allow players outside of your local network to join, you can then also click "Open to Internet" which will attempt to set up an external connection to join your server from the internet. This is done by a technique called UPnP and has to be enabled on your internet router, which it often is by default. In short, we estimate there's about a 60% success chance that 'Open to Internet' works instantly without issues. If it doesn't you would need to set up a so called "port forwarding" on your internet router, which can be tricky and frustrating at times, unfortunately. You would need to forward TCP Port 42420 to your computer in that case. (Google 'Port forwarding' with the name or model of your internet router to find help.)
Line 9: Line 9:
----
----


===Dedicated Server===
=== Dedicated Server ===
Alternatively the game ships with a dedicated server program that you can start and leave on permanently without needing to log in yourself.
Alternatively the game ships with a dedicated server program that you can start and leave on permanently without needing to log in yourself.
There are several ways to get a dedicated server up and running.
There are several ways to get a dedicated server up and running.
Line 22: Line 22:
----
----


=== Dedicated Servers on Linux ===
==== Dedicated Servers on Linux ====
This describes how to set up the server as a service on Linux systems.
This describes how to set up the server as a service on Linux systems.


===== Requirements for CentOS 7 (RHEL, Fedora, ...) =====
===== Requirements =====
'''1. EPEL/screen/wget/curl Install'''


  yum -y install epel-release screen wget curl
* [https://dotnet.microsoft.com/en-us/download/dotnet/7.0 .NET Runtime 7.0] This should be all needed to run a Vintagestory server. Everything else is just for convenience to start and manage it.
* install <code>pgrep</code>, <code>screen</code> and <code>wget</code> using your systems package manager.


'''2. Mono Install'''


  yum -y install yum-utils
===== Setup the server =====
  rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
  yum-config-manager --add-repo http://download.mono-project.com/repo/centos/
  yum -y install mono mono-devel
----
 
===== Requirements for Ubuntu (Debian, Mint, ...) =====
'''1. screen/wget/curl Install'''
 
  sudo apt install -y screen wget curl


'''2. Mono Install'''
'''1. Download the game'''


As of '''Vintage Story version 1.12.7''' and above '''Mono version 5 or higher''' is recommended to use.<br>
<span style="color:#E16100">Advice: ''Create a separate directory for Vintage Story as the tar.gz does not contain a subfolder.''</span>
This '''HowTo is written assuming Ubuntu 18.04''' as the base OS.<br>
To install the latest stable version for your specific distribution, please follow the instructions from the [https://www.mono-project.com/download/stable/#download-lin Official Mono Project Download Page].
  sudo apt install gnupg ca-certificates
  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
  sudo apt update
  sudo apt install -y mono-complete
 
----<br>
 
'''3. Download the game'''
 
<span style="color:#E16100">Advice: ''Create a seperate directory for Vintage Story as the tar.gz does not contain a subfolder.''</span>
   mkdir server && cd server
   mkdir server && cd server


Goto http://account.vintagestory.at/downloads<br>
Goto http://account.vintagestory.at/downloads<br>
Copy the link of the newest "vs_server_*.*.*.tar.gz" package ('''Tar.gz Archive/Linux (server only)''' under '''Show other available downloads of Vintage Story''')<br>
Copy the link of the newest "vs_server_linux-x64_*.*.*.tar.gz" package ('''Linux Server (.tar.gz)''' under '''Show other available downloads of Vintage Story''')<br>
Download with "wget" via console (''Vintage Story version 1.12.9 in this example'').
Download with "wget" via console (''Vintage Story version 1.18.8 in this example'').


   wget https://cdn.vintagestory.at/gamefiles/stable/vs_server_1.12.9.tar.gz
   wget https://cdn.vintagestory.at/gamefiles/stable/vs_server_linux-x64_1.18.8.tar.gz


'''4. Extract tar.gz package'''
'''2. Extract tar.gz package'''


   tar xzf vs_server_*.*.*.tar.gz
   tar xzf vs_server_linux-x64_*.*.*.tar.gz


'''5. Make server.sh script executeable'''
'''3. Make server.sh script executable'''


   chmod +x server.sh
   chmod +x server.sh


'''6. Edit server.sh file'''
'''4. Edit server.sh file'''


For security reasons you should not run the server as root user, so by default USERNAME is set to vintagestory.
For security reasons you should not run the server as root user, so by default USERNAME is set to vintagestory.
Line 87: Line 64:
   VSPATH='<your-vs-directory>'
   VSPATH='<your-vs-directory>'


'''7. Open the port at the firewall (if needed)'''
'''5. Open the port at the firewall (if needed)'''


firewalld
firewalld
Line 95: Line 72:
   iptables -A INPUT -p tcp -m tcp --dport 42420 -j ACCEPT
   iptables -A INPUT -p tcp -m tcp --dport 42420 -j ACCEPT


'''8. Server start and first steps'''
'''6. Server start and first steps'''


  ./server.sh start
    ./server.sh start
 
   Wait for the startup to finish, then you can give yourself OP with
   Wait for the startup to finish, then you can give yourself OP with
   ./server.sh command "/op <youusername>"
   ./server.sh command "/op <youusername>"


'''9. Connect to your IP/Domain and have fun'''
'''8. Connect to your IP/Domain and have fun'''
----
----


===== Requirements for Alpine (Advanced, no support) =====
==== Simple Server start command ====
'''1. Install mono'''
If you want to use a custom script or just manually start your server you can run  
 
dotnet VintagestoryServer.dll --dataPath /path/to/data
As mono is in testing in Alpine, the testing URL (http://dl-cdn.alpinelinux.org/alpine/edge/testing) will have to be uncommented out in
Or
 
./VintagestoryServer --dataPath /path/to/data
  /etc/apk/repositories
if you have the <code>DOTNET_ROOT</code> environment variable set.
 
after, run  
 
  apk update
  apk add mono mono-dev
 
'''2. Install tmux'''
 
  apk add tmux
 
'''3. Certificates'''
 
  apk add ca-certificates
 
then run
 
  cert-sync /etc/ssl/certs/ca-certificates.crt
 
to update the certs.
 
'''4. Simplified Start Script'''
 
Download and extract the server into a location as normal, then put this into a script:
 
  #!/bin/ash
  mono VintagestoryServer.exe --dataPath ./data
 
This script will just run the server, putting the world save files into the same folder the server is extracted to.
As an advanced user, you don't need to worry about having the dependancies, checking for new versions, or installing the server or save files under different users and locations.
 
Run the script in a tmux session.
 
The rest of the normal advice applies too (firewalling etc.).


==== Updating Servers ====
==== Updating Servers ====
Line 187: Line 132:
==== Installation ====
==== Installation ====


'''1. mono Install Debian 9'''
  sudo apt install apt-transport-https dirmngr gnupg ca-certificates wget nano
  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
  sudo apt update
  sudo apt install mono-devel
For Debian 10 use
  echo "deb https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list


'''2. create a user'''
'''1. create a user'''
   adduser --shell /bin/bash --disabled-password gameserver
   adduser --shell /bin/bash --disabled-password gameserver


Line 205: Line 141:
   mkdir -p /usr/lib/systemd/system
   mkdir -p /usr/lib/systemd/system


'''3. Download the game'''
'''2. Download the game'''
   cd /srv/gameserver/vintagestory
   cd /srv/gameserver/vintagestory


Goto http://account.vintagestory.at/downloads<br>
Goto http://account.vintagestory.at/downloads<br>
Copy the link of the newest "vs_server_*.*.*.tar.gz" package ('''Tar.gz Archive/Linux (server only)''' under '''Show other available downloads of Vintage Story''')<br>
Copy the link of the newest "vs_server_linux-x64_*.*.*.tar.gz" package ('''Linux Server (.tar.gz)''' under '''Show other available downloads of Vintage Story''')<br>
Download with "wget" via console (''Vintage Story version 1.12.9 in this example'').
Download with "wget" via console (''Vintage Story version 1.18.8 in this example'').


   wget https://cdn.vintagestory.at/gamefiles/stable/vs_server_1.12.9.tar.gz
   wget https://cdn.vintagestory.at/gamefiles/stable/vs_server_linux-x64_1.18.8.tar.gz


'''4. Extract tar.gz package'''
'''3. Extract tar.gz package'''


   tar xzf vs_server_1.12.9.tar.gz
   tar xzf vs_server_linux-x64_1.18.8.tar.gz
'''5. Change owner'''
 
'''4. Change owner'''


You have to set the owner of your gameserver directory to avoid write permission errors
You have to set the owner of your gameserver directory to avoid write permission errors
   chown -R gameserver:gameserver /srv/gameserver
   chown -R gameserver:gameserver /srv/gameserver


'''6. Create systemd service unit file'''
'''5. Create systemd service unit file'''


Use your favourite tool to create a service unit file (this example uses nano)
Use your favourite tool to create a service unit file (this example uses nano)
Line 233: Line 170:
   [Service]
   [Service]
   WorkingDirectory=/srv/gameserver/vintagestory
   WorkingDirectory=/srv/gameserver/vintagestory
   ExecStart=/usr/bin/mono VintagestoryServer.exe --dataPath /srv/gameserver/data/vs
   ExecStart=dotnet VintagestoryServer.dll --dataPath /srv/gameserver/data/vs
   Restart=always
   Restart=always
   RestartSec=30
   RestartSec=30
Line 245: Line 182:
   WantedBy=multi-user.target
   WantedBy=multi-user.target


'''7. Create config file for rsyslog'''
Make sure the new user has access to the <code>dotnet</code> command or replace the command with the full path to where you installed the dotnet runtime (if you picked a custom install). Or you can also use <code>ExecStart=VintagestoryServer --dataPath /srv/gameserver/data/vs</code> if you have the <code>DOTNET_ROOT</code> environment variable set.
 
'''6. Create config file for rsyslog'''


Use your favourite tool to create a rsyslog config file (this example uses nano)
Use your favourite tool to create a rsyslog config file (this example uses nano)
Line 271: Line 210:
   # Discard  
   # Discard  
   if $programname == 'VSSRV' then ~
   if $programname == 'VSSRV' then ~
'''8. restart rsyslog / enable service'''
'''7. restart rsyslog / enable service'''
To activate rsyslog and your vintagestory server type these commands
To activate rsyslog and your vintagestory server type these commands
   systemctl restart rsyslog.service;
   systemctl restart rsyslog.service;
Line 331: Line 270:
Copy from step 6 and change these lines:
Copy from step 6 and change these lines:
   Description=Vintage Story Server 2 Unit
   Description=Vintage Story Server 2 Unit
   ExecStart=/usr/bin/mono VintagestoryServer.exe --dataPath /srv/gameserver/data/vs2
   ExecStart=dotnet VintagestoryServer.dll --dataPath /srv/gameserver/data/vs2
   SyslogIdentifier=VSSRV2
   SyslogIdentifier=VSSRV2
Create rsyslog file and copy code from step 7
Create rsyslog file and copy code from step 7
43,146

edits