Skip to content

Instantly share code, notes, and snippets.

@cbednarski
Last active April 3, 2024 01:14
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbednarski/3ada27b2c401cc163dc4 to your computer and use it in GitHub Desktop.
Save cbednarski/3ada27b2c401cc163dc4 to your computer and use it in GitHub Desktop.
Host a factorio server

Factorio Server

This guide assumes you are using Ubuntu and have some basic linux command-line know-how.

Download

Download the server https://www.factorio.com/download-headless/stable:

Install

adduser --disabled-login --no-create-home --gecos factorio factorio
mkdir /var/lib/factorio
mkdir /etc/factorio
mkdir /opt/factorio

Extract the archive to /opt/factorio

Factorio User

For security, don't run factorio as root. You'll need to create a user and chmod some things so the factorio user can access them.

adduser --disabled-login --no-create-home --gecos factorio factorio
chown -R factorio:factorio /var/lib/factorio/
chown -R root:root /opt/factorio
chmod -R a+x /opt/factorio/bin/x64/factorio
chmod a+r /etc/factorio/

Startup

Move your save file to /var/lib/factorio/saves and reference by name. You can start the server like this:

/opt/factorio/bin/x64/factorio -c /opt/factorio/config-path.cfg  --start-server zivix2.zip --latency-ms 100 --disallow-commands

Upstart

Make sure the uid/gid corresponds to the factorio user. You can see the correct one to use via:

cat /etc/passwd | grep factorio

Upstart file for /etc/init/factorio.conf

start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]

setuid 1001
setgid 1001

env DAEMON=/opt/factorio/bin/x64/factorio
env OPTS="-c /opt/factorio/config-path.cfg --start-server zivix2.zip --latency-ms 100 --disallow-commands"

respawn
respawn limit 5 5

exec $DAEMON $OPTS

After adding this run:

start factorio

Systemd

Systemd unit file for /usr/lib/systemd/system/factorio.service

[Unit]
Description=Factorio Server

[Service]
Type=simple
User=factorio
ExecStart=/opt/factorio/bin/x64/factorio -c /opt/factorio/config-path.cfg --start-server zivix3.zip --latency-ms 100 --disallow-commands --autosave-interval 10

After adding this run:

systemctl daemon-reload
systemctl start factorio
@pcnate
Copy link

pcnate commented May 26, 2018

you need to be root in order to put and modify files in /opt and /etc. You most likely can use sudo for this as long as you have been given access or own the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment