Guide to Run Monero Node on VPS

Supporting Monero by building new public nodes on VPS or virtual machine.

About a month ago, I host Monero node that is free to use for everyone as a remote RPC. Until this article was written, there were only 2 public nodes from Indonesia and both nodes were run by me.

Hopefully this article can help those of you who want to support Monero by building new public nodes, especially if only a few nodes available in your area or country.

Requirements

As a prerequisite to using this guide, I assume that you already have at least:

  • 1 Virtual Machine (off course) with public IP address.
  • 1GB of RAM (minimum)
  • 160GB of Storage
  • Ubuntu 18.04 (this guide)

I suggest that your VPS use SSD storage, because downloading and verifying the entire blockchains to the spinning hard disk can take 4 - 8 days.

Installation

We need to compile Monero from source.

Dependencies

Build ibgtest-dev binary manually because on Debian/Ubuntu libgtest-dev only includes sources and headers.

1sudo apt-get install libgtest-dev && cd /usr/src/gtest && sudo cmake . && sudo make && sudo mv libg* /usr/lib/

Install remaining dependencies :

1sudo apt update && sudo apt install build-essential cmake pkg-config libboost-all-dev libssl-dev libzmq3-dev libunbound-dev libsodium-dev libunwind8-dev liblzma-dev libreadline6-dev libldns-dev libexpat1-dev doxygen graphviz libpgm-dev qttools5-dev-tools libhidapi-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler libudev-dev

Clone the repository and build

Clone recursively to pull-in needed submodule(s):

1git clone --recursive https://github.com/monero-project/monero

Initialize and update:

1cd monero && git submodule init && git submodule update

change to the most recent release branch (v0.17 when this article is written), and build:

1git checkout release-v0.17
2make

Tips: If your machine has several cores and enough memory, enable parallel build by running make -j<number of threads> or make -j$(nproc) instead of make. For this to be worthwhile, the machine should have one core and about 2GB of RAM available per thread.

The resulting executables can be found in build/Linux/release-v0.17/release/bin.

Copy compiled binary to /opt/monero/bin and change binary files permission:

1mkdir -p /opt/monero
2cp -rv build/Linux/release-v0.17/release/bin /opt/monero/
3chmod -R 775 /opt/monero/bin

Create user and systemd for Monero daemon

Create new user who should run Monero daemon:

1useradd -s /bin/sh -m monerodaemon

Create Monero systemd service file /etc/systemd/system/monero.service and add these following config:

 1[Unit]
 2Description=Monero Daemon
 3After=network.target
 4
 5[Service]
 6Type=forking
 7GuessMainPID=no
 8ExecStart=/opt/monero/bin/monerod \
 9    --rpc-bind-ip 127.0.0.1 \
10    --rpc-restricted-bind-ip [SERVER_PUBLIC_IP_ADDRESS] \
11    --rpc-restricted-bind-port [RPC_RESTRICTED_PORT] \
12    --confirm-external-bind \
13    --public-node \
14    --detach
15Restart=always
16User=monerodaemon
17
18[Install]
19WantedBy=multi-user.target

Change [SERVER_PUBLIC_IP_ADDRESS] above with your server public IP address and [RPC_RESTRICTED_PORT] with your desired port (recommended 18089).

Reload, start and enable daemon on startup:

1systemctl daemon-reload
2systemctl enable --now monero.service

Make sure monero daemon is running: systemctl status monero.service.

Firewall

Make sure your firewall for port 18080 and 18089 ([RPC_RESTRICTED_PORT] from systemd config above) is open, if not:

1ufw allow 18080
2ufw allow 18089