How to Install an OpenTTD Server on Ubuntu 20.04

Updated on April 8, 2021
How to Install an OpenTTD Server on Ubuntu 20.04 header image

Introduction

OpenTTD is an open-source transport simulation game based on Transport Tycoon Deluxe. It is an enhanced version of the original game featuring significant enhancements, including ports to many operating systems, including Windows, OS X, and Linux. With drastically improved gameplay, OpenTTD has, since it's release, gained a cult following and many servers have been founded, allowing players from all over the world to play the game together.

A dedicated server starts and runs an OpenTTD network game, but does not have a local client that takes part. This article aims to show players how they can run their own dedicated OpenTTD server on Ubuntu 20.04.

Prerequisites

Instructions

Download

First, to download the dependencies for OpenTTD, run:

sudo apt install -y fontconfig-config fonts-dejavu-core libasyncns0 libflac8 libfontconfig1 libpulse0 libsdl2-2.0-0 libsndfile1 libvorbisenc2 libwayland-client0 libwayland-cursor0 libwayland-egl1 libxcursor1 libxfixes3 libxi6 libxinerama1 libxkbcommon0 libxrandr2 libxrender1 libxss1 libxxf86vm1 x11-common libfluidsynth2

To locate the current version of OpenTTD, go to this website; look for something similar to:

At the time of writing the latest stable version is 1.11.0.

Now download the .deb file from the official release page, use the latest stable release version that you found in the previous step insted of 1.11.0, just replace all instance of 1.11.0 with whatever your latest version is, e.g. 1.12.3:

wget https://cdn.openttd.org/openttd-releases/1.11.0/openttd-1.11.0-linux-ubuntu-focal-amd64.deb

This will download the release file, version 1.11.0 to the current working directory as the file openttd-1.11.0-linux-ubuntu-focal-amd64.deb.

Installation

To install this file, run the following command:

sudo dpkg -i openttd-1.11.0-linux-ubuntu-focal-amd64.deb

Graphics must be installed to be able to start an OpenTTD server. To do this, first, download them from the official OpenTTD binaries source:

wget https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip

Install unzip to decompress this file:

sudo apt install -y unzip

Now unzip this downloaded file:

unzip opengfx-0.6.0-all.zip

Now decompress this tarball:

tar -xvf opengfx-0.6.0.tar

You can now move the graphics set to the server configuration folder. Use the following command:

mv opengfx-0.6.0 ~/.openttd/baseset

Deployment

Firstly, to run an application in the background, the GNU project screen can be used. To download and install screen, run:

sudo apt install -y screen

To open a screen, type:

screen

Press Enter. To confirm that screen is working, press Ctrl + A, then press V; you should see a bar at the bottom of the terminal that is similar to:

screen 4.08.00 (GNU) 05-Feb-20

The server can now be started using the following command:

openttd -D

You should see the following text:

dbg: [net] [udp] listening on IPv4 port 0.0.0.0:3979 (IPv4)
dbg: [net] [udp] listening on IPv6 port [::]:3979 (IPv6)
dbg: [net] Generating map, please wait...
dbg: [net] Map generation percentage complete: 5
dbg: [net] Map generation percentage complete: 10
dbg: [net] Map generation percentage complete: 15
dbg: [net] Map generation percentage complete: 20
dbg: [net] Map generation percentage complete: 25
dbg: [net] Map generation percentage complete: 30
dbg: [net] Map generation percentage complete: 35
dbg: [net] Map generation percentage complete: 40
dbg: [net] Map generation percentage complete: 45
dbg: [net] Map generation percentage complete: 50
dbg: [net] Map generation percentage complete: 55
dbg: [net] Map generation percentage complete: 60
dbg: [net] Map generation percentage complete: 65
dbg: [net] Map generation percentage complete: 70
dbg: [net] Map generation percentage complete: 75
dbg: [net] Map generation percentage complete: 80
dbg: [net] Map generation percentage complete: 85
dbg: [net] Map generation percentage complete: 90
dbg: [net] Map generation percentage complete: 99
dbg: [net] Map generated, starting game

This means your server is working properly and generating the map fully, allowing the game to start.

Configuration

To stop the server, press Ctrl + C. The settings of the server should be customised as seen fit. Some settings need to be changed though. To edit the config file, edit the openttd.cfg file as follows:

nano ~/.openttd/openttd.cfg

To allow users to connect to your server from other networks, locate the line that says:

lan_internet = 1

and replace the 1 with a 0, so it looks like:

lan_internet = 0

To change the name of the server on the server list to that which you wish to name your OpenTTD server, locate the line that says:

server_name = Unnamed Server

and change Unnamed Server as necessary.

If you want your server to be discoverable by anyone who plays OpenTTD, locate the line that says:

server_advertise = false

and replace the false with a true.

If you want the game to be paused when no players are online, you will want to edit the line that says:

min_active_clients = 0

and change the 0 to a 1.

The settings are highly customizable, so if you have specific requirements, you can find out about all of the config fields available here.

Conclusion

To start the server again, run:

openttd -D

To stop the server, press Ctrl + C.

To exit the shell with the server running in the background, press Ctrl + A and then D.

When you log back into the server shell, type the following to get back to the server process:

screen -r

In conclusion, you should now have an OpenTTD dedicated server running in the background on your Vultr Ubuntu 20.04 VPS instance. You should be able to modify it as you please and allow players from all around the world to play on your server.