Updated API and Explorer Deployment

Server Setup on Ubuntu 20.04 LTS

SSH into the server

ssh USER@URL

Create new sudo user

adduser NEWUSER

usermod -aG sudo NEWUSER

su - NEWUSER

Add Swap Space

free -h

df -h

sudo fallocate -l 4G /swapfile

ls -lh /swapfile

sudo chmod 600 /swapfile

sudo mkswap /swapfile

sudo swapon /swapfile

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Install Nginx

sudo apt update

sudo apt upgrade

sudo apt install nginx

sudo ufw allow 'Nginx Full'

sudo ufw allow 'OpenSSH'

sudo ufw allow 4888

sudo ufw enable

Secure Nginx with HTTPS

sudo apt-get update

sudo apt-get install python3-certbot-nginx

sudo nano /etc/nginx/sites-available/default


server_name DOMAINURL;

add_header Access_Control_Allow-Origin "https://wallet.htmlcoin.com";

location / {

proxy_pass http://localhost:3000;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}

location /api/ {

proxy_pass http://localhost:7001/;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection 'upgrade';

proxy_set_header Host $host;

proxy_cache_bypass $http_upgrade;

}



sudo nginx -t

sudo systemctl restart nginx.service

sudo certbot --nginx -d DOMAINNAME

Install node.js

cd ~

curl -sL https://deb.nodesource.com/setup_12.x -o nodesource_setup.sh

sudo bash nodesource_setup.sh

sudo apt install nodejs

sudo apt install build-essential

Install nvm -

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash


export NVM_DIR="$HOME/.nvm"


[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm


[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

Install mongo

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -


echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list


sudo apt-get update

sudo apt-get install -y mongodb-org

sudo systemctl start mongod

sudo systemctl enable mongod

Install Dependencies

Ubuntu 18 - sudo add-apt-repository ppa:bitcoin/bitcoin

Ubuntu 20 - sudo snap install bitcoin-core


sudo apt-get install libzmq3-dev gcc g++ build-essential libtool autotools-dev automake pkg-config bsdmainutils python3 libgmp3-dev libdb5.3-dev libdb5.3++-dev screen libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev autotools-dev automake libtool pkg-config python-is-python3

Install MySQL

wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.20-1_all.deb

sudo apt-get update

sudo apt-get install mysql-server

sudo mysql_secure_installation

sudo systemctl enable mysql

Create and Initiate MySQL Database

wget https://raw.githubusercontent.com/denuoweb/htmlcoininfo/master/doc/structure.sql


sudo mysql -u root -p;


mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';

mysql> flush privileges;

mysql> CREATE DATABASE htmlcoin_mainnet;

mysql> USE htmlcoin_mainnet;

mysql> source structure.sql;

mysql> exit

Install Redis

sudo add-apt-repository ppa:redislabs/redis

sudo apt-get update

sudo apt-get install redis

redis-server --daemonize yes


Deploy Htmlcoin

git clone --recursive https://github.com/htmlcoin/htmlcoin.git --branch=htmlinfo

cd htmlcoin/depends/

make

git submodule update --init --recursive

cd ..

./autogen.sh

./configure --disable-shared --enable-cxx --enable-static --enable-bitcore-rpc --prefix=`pwd`/depends/x86_64-pc-linux-gnu --without-gui --without-miniupnpc

make clean

make -j4

Edit Config

sudo nano ~/.htmlcoin/htmlcoin.conf


rpcuser=USERNAME

rpcpassword=PASSWORD

port=4888

rpcport=4889

rpcallowip=127.0.0.1

whitelist=127.0.0.1

zmqpubrawtx=tcp://127.0.0.1:28333

zmqpubhashblock=tcp://127.0.0.1:28333

server=1

txindex=1

addressindex=1

timestampindex=1

spentindex=1

addrindex=1

dbcache=8192

checkblocks=144

maxuploadtarget=1024

logevents=1

gen=0

maxconnections=500

rpcworkqueue=300


Run Htmlcoin

mkdir ~/.htmlcoin

sudo chown USER:USER ~/.htmlcoin/ -R

screen -t htmlcoind -S htmlcoind

cd src/

./htmlcoind

Deploy htmlcoininfo-api

cd ~

nvm i v12

git clone https://github.com/denuoweb/htmlcoininfo-api.git


cd htmlcoininfo-api && sudo rm -rf package-lock.json && npm install && npm install esm && npm audit fix

Create config/config.prod.js, write your configurations into config/config.prod.js such as:

exports.security = {

domainWhiteList: ['https://URL'] // CORS whitelist sites

}

exports.cors = {

origin: '*' // Access-Control-Allow-Origin: *

}

exports.sequelize = {

logging: false // disable sql logging

}

Edit config/config.default.js

exports.sequelize = {

username: 'USER'

password: 'PASSWORD'

}

exports.htmlcoininfo = {

rpc: {

port: PORT,

user: USER,

password: PASSWORD,

Run htmlcoin-api egg

npm start

Deploy htmlcoininfo-ui

Run

cd ~

git clone https://github.com/denuoweb/htmlcoininfo-ui.git

cd htmlcoininfo-ui && npm install && npm audit fix

Edit script.build:

sudo nano package.json

Run

npm run build

npm start

Deploy htmlcoininfo

11/17 11:49:43 Start --- 11/19 13:59:45 Finish

cd ~

git clone https://github.com/denuoweb/htmlcoininfo.git

nvm i 12

cd htmlcoininfo && npm install && npm audit fix

Edit Config

sudo nano htmlcoininfo-node.json

and change the mysql username, password, and database name, along with changing the RPC username and password.

Run Htmlcoininfo

npm run dev

(run htmlcoininfo under a process manager (like pm2), to restart the process when htmlcoininfo crashes)