Running BTCPay + WooCommerce on a single server for $4/month

BTCPay Server
7 min readJan 31, 2019

--

This proof of concept article shows how to run BTCPay Server (full Bitcoin and Lightning node) with WooCommerce on a single VPS for around $4/month.

The goal is to showcase the cheapest possible way you can have a small self-sovereign e-store and earn Bitcoin by selling products or services.

Please understand that we’re using the most cost-effective solution that will work only if you have a tiny store with a few products to sell.

You can replicate the setup without using a trusted full node (Full sync) on a slightly more powerful VPS. If you already have BTCPay server, skip the bottom.

More robust stores should go with higher specs servers which will cost from $10/mo, depending on the hosting provider of your choice. Take a look at our documentation for ways you can deploy BTCPay, from deployment to a cloud to Raspberry Pi.

The dirty-cheap setup featured here is just a proof of concept. Treat it as an experiment.

This tutorial assumes you have basic command line and WordPress knowledge. If you’re a complete beginner and want to create an online store from scratch with no coding skills, check this video series.

Creating a virtual machine

We are going to use the M1s plan on LunaNode as our VPS provider. The setup should work on any other VPS with the following minimum specs:

  • 1 GB RAM
  • 1 Virtual Core
  • 35 GB SSD Storage (15GB+ 20 GB attached additionally)
  • 1000 GB Bandwidth

The price is $3.5/month + $0.03 for additionally attached GB to our storage, which brings the price around 4.1$/month.

  1. Purchase and create a new virtual machine.
  2. Enable CPU utilization.
  3. Create additional 20GB volume and attach it to the virtual machine.
Creating a virtual machine

Enabling CPU Utilization and adding additional storage

The following instructions are LunaNode-specific. If you have a more powerful VM, you can skip to DNS Configuration right away.

CPU Utilization

Since the machine on LunaNode’s plan does not have sufficient storage, we’d have to attach additional volume and also enable CPU Utilization.

  1. In dashboard, click “virtual machines” and click on your virtual machine.
  2. Under CPU tab, enable CPU utilization.
Enabling CPU utilization to prevent being throttled and copying the external IP which we will need for the next step — DNS configuration

Creating 20 GB volume

Next, we’re going to attach 20 GB of additional storage space.

  1. Go to “Volumes” in the dashboard.
  2. Select volume location from the drop-down menu, add the name and write 20 gb or more in the size field. 1GB of extra volume will cost you 0.03$.
  3. Create volume
In this tutorial we attached 20GB. You’re free to attach more if you want, just to be safe.

Attaching a volume to VM

  1. In your LunaNode Dashboard, click volumes.
  2. In Volumes, scroll down to the “Volume List”
  3. Find the volume you previously created and click on to “Manage”
  4. When the volume opens, choose “Attach to VM”
  5. In the pop-up window, choose the virtual machine to which you want to attach the volume.
  6. Attach volume to VM

DNS Configuration

Now that we’ve set up the virtual machine, we have to point our domain names to the external IP of the machine.

You need two domains or two subdomains.

If you don’t have a domain name yet, we recommend EasyDNS or Gandi.net. Both accept Bitcoin and provide great service.

In our example, domain name is yourdomain.com. On that domain, we want to have btcpay subdomain and woocommerce subdomain: btcpay.yourdomain.com and store.yourdomain.com.

Put the external IP in both of those domains and set them as an a-record domains.

Configuring DNS

Deploying BTCPay Server and WooCommerce

Now that we created a virtual machine, configured it and pointed the external IP properly, it’s finally time to deploy BTCPay.

Open your terminal and log in into your machine.

ssh ubuntu@btcpay.yourdomain.com

then do:

sudo su -

Format and mount the additional 20GB volume we attached earlier (if your VPS has sufficient storage space, you can skip this part)

mkfs.ext4 /dev/vdc
mkdir /mnt/dockervolume
mount /dev/vdc /mnt/dockervolume
echo "/dev/vdc /mnt/dockervolume ext4 defaults 0 0" >> /etc/fstab

Then set docker to use the volume

ln -s /mnt/dockervolume /var/lib/docker

Next, install git:

apt-get update && apt-get install -y git

Once over, you need to clone btcpayserver-docker and go inside that directory, install docker and set your environment variables.

Replace the text in bold with your own. We’re here setting our BTCPay and WooCommerce environment.

git clone https://github.com/btcpayserver/btcpayserver-docker
cd btcpayserver-docker
export BTCPAY_HOST="btcpay.yourdomain.com"
export NBITCOIN_NETWORK="mainnet"
export BTCPAYGEN_CRYPTO1="btc"
export BTCPAYGEN_REVERSEPROXY="nginx"
export BTCPAYGEN_LIGHTNING="lnd"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-xs;opt-save-memory"
export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-woocommerce"
export WOOCOMMERCE_HOST="store.yourdomain.com"

In case you want to use different database default password and username (which is recommended) please take a look at all of the variables you can modify.

The last step is to launch the BTCPayServer setup script.

. ./btcpay-setup.sh -i

Don’t close your terminal. Wait for the setup to complete (takes around 5–10 minutes).

Visit your btcpay.youromain.com and store.yourdomain.com to make sure they open up correctly.

BTCPay needs to sync. In case you don’t know, it comes with full Bitcoin and Lightning Network node. Your node needs to download and validate the entire blockchain.

Since we’re using an underpowered machine, the syncing process will crash it. That’s why we must use a workaround, called the FastSync.

Please read very carefully to understand what FastSync is and why it’s important to verify the UTXO set yourself. Simply said, we will be using a trusted node to speed up the validation process.

If you have a machine which meets minimal requirements, you can skip this step and let your node validate the entire blockchain without having to trust anyone.

./btcpay-down.sh
cd contrib
cd FastSync
./load-utxo-set.sh

Depending on your bandwidth, downloading the blockchain synced from a trusted node will take 10 minutes. After FastSync is finished, run the following command:

btcpay-up.sh

The rest has to be validated by your node. That process usually lasts 3–6 hours.

Until your BTCPay fully syncs, you can set up your store at store.yourdomain.com and set it up via the WordPress wizard. We won’t go into details on how to set up WordPress site in this article.

You should have WooCommerce and BTCPay Woo plugin pre-installed. Activate them. Add a theme (Storefront is quite decent) and activate it as well.

Here are some helpful articles:

  1. Getting Started with BTCPayServer
  2. WooCommerce and BTCPay pairing
  3. Lightning Network guide

Hopefully you found the article useful, once again, we highly recommend that you use slightly better plan and fully sync your node.

Already have BTCPay Server?

If you already have BTCPay Server, you can very easily start WooCommerce in your existing environment.

First, point the external IP of your BTCPay to your store domain.

Log into your BTCPay server as root.

sudo su -

Set up WooCommerce variables. You can add optional variables as well.

export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-woocommerce"
export WOOCOMMERCE_HOST="yourstoredomain.com"

Lastly, just run BTCPay Setup script which will add the set up variables.

. ./btcpay-setup.sh -i
If you like minimal design inspired by Zap wallet in our demo store, you can grab some of the CSS here.

If you have any questions about this tutorial, feel free to leave a comment or join our growing community on Mattermost chat.btcpay.server.org.

--

--