Running BTCPay + WooCommerce on a single server for $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.
- Purchase and create a new virtual machine.
- Enable CPU utilization.
- Create additional 20GB volume and attach it to the 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.
Since the machine on LunaNode’s plan does not have sufficient storage, we’d have to attach additional volume and also enable CPU Utilization.
- In dashboard, click “virtual machines” and click on your virtual machine.
- Under CPU tab, enable CPU utilization.
Creating 20 GB volume
Next, we’re going to attach 20 GB of additional storage space.
- Go to “Volumes” in the dashboard.
- 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$.
- Create volume
Attaching a volume to VM
- In your LunaNode Dashboard, click volumes.
- In Volumes, scroll down to the “Volume List”
- Find the volume you previously created and click on to “Manage”
- When the volume opens, choose “Attach to VM”
- In the pop-up window, choose the virtual machine to which you want to attach the volume.
- Attach volume to VM
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.
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.
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.
sudo su -
Format and mount the additional 20GB volume we attached earlier (if your VPS has sufficient storage space, you can skip this part)
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
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.
Depending on your bandwidth, downloading the blockchain synced from a trusted node will take 10 minutes. After FastSync is finished, run the following command:
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.
Here are some helpful articles:
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.
Lastly, just run BTCPay Setup script which will add the set up variables.
. ./btcpay-setup.sh -i
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.