Go to http://www.factorio.com/download-headless/stable and download the latest stable. As of this writing, that would be 0.12.26
The headless server is a tarball of a (mostly?) statically-compiled server along with data. You will need to extract it and put it into a directory. Since this is a 3rd-party program, not managed by the package manager, I feel like /opt
is a good choice.
tar xf factorio_headless_x64_0.12.26.tar.gz
sudo mv factorio /opt
sudo chown -R root:root /opt/factorio
Before starting and publishing your server, you need to generate the initial map. Nice and simple:
sudo /opt/factorio/bin/x64/factorio --create SAVE_NAME
This will create the map called SAVE_NAME.zip in /opt/factorio/saves
. If you include a /, subdirectories will be made automatically for you. Useful to namespace a user's saves. However, autosaves will always be called _autosaveN.zip
, so I'd guess if you're hosting multiple instances there could be conflicts.
SystemD is the best init daemon for Linux, in my opinion. So here's a unit file to manage running instances:
[Unit]
Description=Factorio game server
Documentation=http://www.factorio.com/
[Service]
Type=simple
ExecStart=/opt/factorio/bin/x64/factorio --start-server=SAVE_NAME
User=root
WorkingDirectory=/opt/factorio/
[Install]
WantedBy=multi-user.target
This is a quick & lazy unit file, a better one could possibly be made. Otherwise, just edit the ExecStart
line above to use the same SAVE_NAME as the one you generated earlier.
Just found out about https://github.com/trast/factorio-screenshots, the server is brand new so it won't be interesting just yet, but I'll probably update this later on.