0% found this document useful (0 votes)
5 views6 pages

Docs

The document outlines the setup process for a BTCPay server and a backend server, requiring two VPS and two domains. It includes detailed instructions for installing necessary software, configuring the servers, setting up a database, and running background processes. Finally, it provides guidance on configuring Nginx to make the site accessible through the specified domains.

Uploaded by

kkdipak89
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Docs

The document outlines the setup process for a BTCPay server and a backend server, requiring two VPS and two domains. It includes detailed instructions for installing necessary software, configuring the servers, setting up a database, and running background processes. Finally, it provides guidance on configuring Nginx to make the site accessible through the specified domains.

Uploaded by

kkdipak89
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Documentation

Requirements
2 vps

btcpay server : minimal requirements where to run a pruned node


around 5gb

bot + backend server

2 domains

1 pointing to the btcpay server ( call it domain1)

2 pointing to the backend server ( call it domain2)

Setting up btcpay
login to the server through ssh

follow these steps ( the text starting with // is instructions

// use root for simplicity you can use this


sudo su

// Create a folder for BTCPay


mkdir BTCPayServer
cd BTCPayServer

// Clone this repository


git clone [Link]
cd btcpayserver-docker

// configure btcpay
export BTCPAY_HOST=domain1
export BTCPAYGEN_CRYPTO1=ltc
export NBITCOIN_NETWORK=mainnet
export BTCPAYGEN_LIGHTNING=
export BTCPAYGEN_REVERSEPROXY=nginx

Documentation 1
export BTCPAYGEN_ADDITIONAL_FRAGMENTS=opt-save-storage-xxs

// install btcpay

. ./[Link] -i

when this is complete just open the browser and access btcpay throguh
domain1 it will ask you to create your domain account

after that go to your btcpay account settings and create an api key ( full
permissions )

for the sake of the guide let’s call it : apikey1

Setting up the backend


login to the second server

install necessary packages

sudo apt install python3-pip python3-virtualenv nginx redis redis-server git

setup the backend

sudo mkdir /www


cd /www
sudo mkdir /source
cd /source

now you are inside the source folder

clone the repo

git clone <repo:url>

create a virtual environment

python3 -m virtualenv workenv

activate the virtualenv

Documentation 2
source workenv/bin/activate

install the backend packages

cd market/backend/
pip install -r [Link]
pip install gunicorn

Setup the database

sudo -u postgres psql


CREATE DATABASE tgbot;
CREATE USER tguser WITH PASSWORD 'tgPass@123'; // you can adjust thi
s
GRANT ALL PRIVILEGES ON DATABASE tgbot TO tguser;
\c tgbot
GRANT ALL ON SCHEMA public TO tguser;
GRANT USAGE ON SCHEMA public TO tguser;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO tguser;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO tguse
r;

Setup the .env

// back to the backend source folder


cd /www/source/market/backend/ecomBot
vim .env

// now paste this


BTC_PAY_API_KEY=apikey
BTC_PAY_HOST=[Link]
NETWORK= 0
# network : 0 : mainnet || 1 : testnet
BOT_WORKING_DIR = "/www/source/market/NewBot"
PYTHON_PATH = "/www/source/workenv/bin/python3"

Documentation 3
#sqlite
DATABASE = "postgresql"
DEBUG=True
# you can add as many domains you like domain1,domain2 ...
ALLOWED_HOSTS=domain2
# Database config
DB_NAME=tgbot
DB_USER=tguser
DB_PASSWORD=tgPass@123
DB_HOST=localhost
DB_PORT=5432

save it and run this ( make sure the virtual environment is active )

python [Link] migrate

// if this runs then your database is connected


// after that you can run the app
python -m gunicorn --bind [Link]:8080 [Link] --daemon

Run the background processes


create a seperate screen session

// scheduler
screen -R beat
cd /www/source
source workenv/bin/activate
cd backend/ecomBot
python -m celery -A ecomBot beat -l INFO --scheduler django_celery_beat.
schedulers:DatabaseScheduler

// use ctrl + a + d to detach from the current session

// worker
// we do the same for the worker
screen -R worker
cd /www/source

Documentation 4
source workenv/bin/activate
cd backend/ecomBot
python -m celery -A ecomBot worker -l INFO

// now the background script is running

Setup nginx

// edit conf
vim /www/source/backend/conf
// you will find this
server {
listen 8000; // this have it on 80 or ssl port depends on which port you w
ant to run the app
server_name domain2; // adjust this to your domain
client_max_body_size 5M;

# Static files (CSS, JS, images) from /assets


location /assets/ {
alias /www/source/market/backend/ecomBot/assets/;
access_log off;
expires max;
}

# Media files (user uploads, images) from /media


location /media/ {
alias /www/source/market/backend/ecomBot/media/;
access_log off;
expires max;
}

# Proxy pass everything else to Gunicorn


location / {
proxy_pass [Link]
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Documentation 5
proxy_set_header X-Forwarded-Proto $scheme;
}
}

when done save the file

copy the file

cp /www/source/market/backend/conf /etc/nginx/sites-available/site
ln -s /etc/nginx/sites-available /etc/nginx/sites-enable
sudo systemctl restart nginx

Now your site should be accessible through domain2

Documentation 6

You might also like