How to Setup and Run a Bitcoin Full Node on Ubuntu 18.04

install Dependencies

add-apt-repository ppa:bitcoin/bitcoin
apt-get update
apt-get install -y libdb4.8-dev libdb4.8++-dev  unzip


wget http://download.oracle.com/berkeley-db/db-4.8.30.zip
unzip db-4.8.30.zip
cd db-4.8.30
sed -i 's/__atomic_compare_exchange/__atomic_compare_exchange_db/g' dbinc/atomic.h

cd build_unix/

../dist/configure --prefix=/usr/local --enable-cxx

make

make install

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"




apt-get install -y libboost-all-dev libzmq3-dev libminiupnpc-dev  curl git build-essential libtool autotools-dev

apt-get install -y automake pkg-config bsdmainutils python3 software-properties-common libssl-dev libevent-dev

apt install libsqlite3-dev -y

add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update
apt install g++-10 -y

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10

install Bitcoin Core (test version):

cd /usr/src
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
./autogen.sh
./configure

make
cd src
install -sv bitcoind bitcoin-cli /usr/local/bin/

install Bitcoin Core (stable version): get newest from : https://github.com/bitcoin/bitcoin/tags

cd /usr/src
wget https://github.com/bitcoin/bitcoin/archive/refs/tags/v23.0rc3.tar.gz
cd bitcoin-23.0rc2/
./autogen.sh
./configure

make
cd src
install -sv bitcoind bitcoin-cli /usr/local/bin/

configure bitcoin

mkdir ~/.bitcoin
vi $HOME/.bitcoin/bitcoin.conf

rpcuser=mehdibtcnode
rpcpassword=strong-password
server=1
txindex=1

start bitcoin daemon

bitcoind --daemon

look at bitcoin log

tail -f ~/.bitcoin/debug.log

add to rc.local

echo "bitcoind --daemon" >> /etc/rc.local 

/etc/rc.local should look like this:

#!/bin/bash
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
bitcoind --daemon

useful commands:

bitcoin-cli -getinfo
bitcoin-cli getblockchaininfo
bitcoin-cli getnetworkinfo
bitcoin-cli getpeerinfo

By: Mehdi Sadighian
Contact: mehdi.sadighian@hotmail.com
TAG: Bitcoin, BTC, bitcoin node, btc node, Bitcoin Full Node, Bitcoin Core, bitcoind, Bitcoin Daemon