Install & Configure Factorio on Linux
I've had several requests for a follow on post to Factorio Server on Google Cloud with steps to actually download and configure Factorio. Lucky for you all I just re-built my factorio server last night and grabbed everything I did from my bash history:
All of the instructions here assume you have sudo access to the machine you are doing this install on. More specifically these are the steps I followed to setup my Google Compute Engine server.
sshto the machine you are going to be using.- I find being able to do
sudo -ueasier than doingsudo suso first thing is to makes sure I have that permission.
sudo visudo- Change
ALL=NOPASSWD: ALLentries toALL=(ALL) NOPASSWD: ALLusing the editor that comes up - Save the changes (usually ctrl+x then answer Y at the prompt for the default editor nano)
- Create a
factoriouser, this is the user that will run the server and own the related files
sudo useradd factorio
- We will install everything in
/opt
cd /opt
- Download the factorio-init script
sudo git clone https://github.com/Bisa/factorio-init.git
- Download the factorio-updater script
sudo git clone https://github.com/narc0tiq/factorio-updater.git
- Download & extract the factorio server. Get the latest stable or experimental download link.
sudo wget https://www.factorio.com/get-download/0.13.13/headless/linux64- EDIT: Login credentials are now required to download the headless server. You now need to go to https://www.factorio.com/download-headless/experimental manually download the file and then transfer it to your server via scp.
sudo tar -xzvf linux64sudo rm linux64
- Everything we just did is currently owned by
root, we want thefactoriouser to actually own everything so change the owner user and group for everything factorio related under/opt
sudo chown -R factorio:factorio /opt/factorio*
- Install & Configure the factorio-init script
sudo -u factorio cp /opt/factorio-init/config.example /opt/factorio-init/configsudo cp /opt/factorio-init/factorio.service.example /etc/systemd/system/factorio.servicesudo -u factorio vim /opt/factorio-init/config- Change the following settings:
UPDATE_SCRIPT=/opt/factorio-updater/update_factorio.pyUPDATE_USERNAME=yourfactoriousername(put in your factorio.com user name)- Comment out the
UPDATE_TOKENline (put a # at the start of the line) - Set
UPDATE_EXPERIMENTALto 1 if you want to use the experimental builds instead of stable.
- Configure factorio
sudo -u factorio cp /opt/factorio/data/server-settings.example.json /opt/factorio/data/server-settings.jsonsudo -u factorio vim /opt/factorio/data/server-settings.json- Set the
name,description, andtagsto whatever values you want. These are used to help people find the server. - IF you want to use the factorio matching server (browse public games) set
usernameandpasswordto your factorio.com username and password - Set a
game_passwordunless you want anyone to be able to join your server - I personally have
verify_user_identityset to false as I run a password protected server for friends I trust. I believe setting this false would let a malicious actor spoof their player name and play as other users.
- Set the
- Manually launch the server for initialization and to create the first save
sudo -u factorio /opt/factorio/bin/x64/factorio --create /opt/factorio/saves/
- Verify the server starts
sudo systemctl start factoriosudo systemctl status -l factorio- Remember to enable the service at startup if you want that:
sudo systemctl enable factorio
From here on out you can follow the (factorio-init)[https://github.com/Bisa/factorio-init/blob/master/README.md#systemd] help docs on how to start/stop/update the server. Running sudo -u factorio /opt/factorio-init/factorio will also give a list of commands that the script can run for you.
With this setup the factorio server should start when the server boots and gracefully stop when the server shuts down. This is really handy if you want to pinch pennies and only run your GCE server when you actually play on it.
Posted Aug 3, 2016, 5:15 PM UTC · edited