Cryptocurrency Exchange Installation (Peatio) In Ubuntu System

11 Mar 2019
0 Comments
Cryptocurrency Exchange Installation (Peatio) In Ubuntu System

Peatio is an open-source cryptocurrency exchange web application. Here you will be going to have your own cryptocurrency exchange. For the installation of Peatio, you should have a fresh Ubuntu system along with minimum 4GB RAM and 1 TB SSD.

 

Prerequisites

Now Start with the installation of following technology stack required for the Peatio configuration and installation.

  1. Redis server

  2. RabbitMQ

  3. MySQL database

  4. Bitcoind

  5. Nginx with Passenger

  6. JavaScript Runtime

 

Step 01: Install Redis with a stable version

Redis is basically used in Peatio for storing session data as well as trading data, that needs to be transferred from one application to another.
 

sudo apt-get update

sudo apt-get install redis-server

 

Now you can configure the redis.conf file as per the requirements

sudo nano /etc/redis/redis.conf

 

Step 02: Install RabbitMQ Server

RabbitMQ is used for exchange the data between servers, applications, and processes.
It uses the Advanced Message Queuing Protocol (AMQP) to exchange the data between peatio and the coin servers like bitcoind, ethereum, rippled, etc.

 

Install the rabbitmq-server by using the following commands.

 

sudo apt-get update

sudo apt-get install rabbitmq-server

 

To start the rabbitmq-server first enable the rabbitmq management plugin and then restart it.

 

sudo rabbitmq-plugins enable rabbitmq_management

 

sudo service rabbitmq-server restart

 

Same like above command we can use start, stop and status for checking the status of rabbitmq-server.

 

Step03: Install MySQL Database

Here we are going to install the mysql database.

sudo apt-get update

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

 

Step 04: Installation and Configuration of Bitcoind Server

Bitcoind is a program or daemon which implements bitcoin protocols for remote procedure call (RPC).
When the Bitcoind get installed in the Ubuntu system, it started syncing blocks of blockchain of Bitcoin. Once the difference between the current block and synced block is getting the same then we can make transaction form our local system.


Installation

First, install the dependencies then install bitcoind server.
 

sudo apt-get update

sudo apt-get install bitcoind

 

Configuration

Here we can configure the bitcoind server for testnet as well for real Bitcoin network.
 

mkdir -p ~/.bitcoin

touch ~/.bitcoin/bitcoin.conf

nano ~/.bitcoin/bitcoin.conf

 

Now insert the following lines into the bitcoin.conf file and replace with your ’s rpcuser and rpcpassword.

 

server=1

 

daemon=1

 

# If run on the test network instead of the real Bitcoin network

 

testnet=1

 

rpcuser=USERNAME

 

rpcpassword=PASSWORD

 

rpcport=18332

 

# Notify when receiving coins

 

walletnotify=/usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "currency":"btc"}'

 

Now we can start bitcoind server using the following command or we can use bitcoin-cli for further operations.

 

bitcoind

 

Step 05: Nginx Installation

Nginx is an open-source web server which is used for low memory uses and high concurrency. It handles the high numbers of connections and acts as a load balancer to manage traffic and distribute it.
 

sudo apt-get update

sudo apt-get install nginx

sudo ufw allow 'Nginx HTTP'

systemctl status nginx

 

Now configure the default config file to setup Nginx with reverse proxy

open file ‘/etc/nginx/sites-available/default’ in an editor and replace the file content with the following

 

#

 

# ATTENTION!

 

#

 

# Make sure to add the next line to /etc/hosts.

 

#

 

server {

 

server_name http://localhost:3000;

 

listen 80 default_server;

 

location ~ ^/(?:trading|trading-ui-assets)\/ {

 

proxy_pass http://localhost:5000;

 

}

 

location / {

 

proxy_pass http://localhost:3000;

 

}

 

}

 

 

Make sure to replace http://localhost:3000 with your actual server.

 

You can verify the syntax of the config file is valid or not.

 

sudo nginx -t

 

and then restart the nginx server

 

sudo systemctl restart nginx

 

Step 06: Install JavaScript Runtime

The JavaScript Runtime is used for assets pipeline to work.

 

curl -sL https://deb.nodesource.com/setup_8.x | sudo bash -

 

sudo apt-get install nodejs

 

Installation & Configuration of Peatio

First, take the clone of peatio form GitHub

 

mkdir cryptocurrency_exchange

 

cd cryptocurrency_exchange

 

git clone https://github.com/rubykube/peatio.git

 

cd peatio

 

use rvm 2.5.1

 

bundle install

 

now prepare the configuration files

 

bin/init_config

 

install and run the yarn

 

npm install -g yarn

 

bundle exec rake tmp:create yarn:install

 

Setup bitcoind rpc endpoints

 

Edit ‘config/seed/currencies.yml’

 

Replace ‘username:password’ and ‘port’

 

remember username:password should only contain letters and numbers not email address as a username.

 

Setup database for peatio

 

Edit ‘config/database.yml’ replace your database username and password. And run the commands.

 

bundle exec rake db:create

 

bundle exec rake db:migrate

 

bundle exec rake currencies:seed

 

bundle exec rake markets:seed

 

Run daemons

in the peatio directory

 

god -c lib/daemons/daemons.god

 

you can use commands like god start, god restart and god status daemon

 

Setup Authentication

By default peatio uses the google authentication, you can also use barong for the authentication.
Change the sign in provider as per your requirement in “/config/application.yml”

 

Run Peatio

Here we can start the server and run the Peatio application.
 

bundle exec rails s -p 3000

 

Here we can see the Peatio is running now.






Cryptex Technologies is a Cryptocurrency Exchange Development Company in India. We hold expertise in all the aspects i.e. installation, integration, customization, deployment, and maintenance of code for cryptocurrency Exchange.

 




Leave a comment: