Mohan pd.
Mohan pd. Author of The Coders Blog. Also a professional fullstack javascript developer working with various tech company and client around world.

Install Peatio on Server. Complete Guide

Sep 27, 2019 · 7 minutes
Install Peatio on Server. Complete Guide

Peatio is an open-source crypto currency exchange program. It is implementation with the rails framework and other cutting edge technology. In this article we will setup the Peatio for production. This article is organized in step by process as listed below.

Table of Contents

  1. Setup deploy user
  2. Install Ruby
  3. Install MySQL
  4. Install Redis
  5. Install RabbitMQ
  6. Install Bitcoind
  7. Install Nginx with Passenger
  8. Install JavaScript Runtime
  9. Install ImageMagick
  10. Configure Peatio
  11. Setup Pusher
  12. Setup Bitcoin RPC
  13. Run Daemons
  14. Setup Google authentication
  15. Setup Auth0
  16. Run Peatio
  17. Setup nginx

Setup deploy user

Create (if it doesn’t exist) deploy user, and assign it to the sudo group:

    sudo adduser deploy
    sudo usermod -a -G sudo deploy

Re-login as deploy user

    su deploy

Install Ruby

  • Make sure your system is up-to-date.
sudo apt-get update
sudo apt-get upgrade
  • Installing dependencies
sudo apt-get install git curl zlib1g-dev build-essential \
  libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \
  libxml2-dev libxslt1-dev libcurl4-openssl-dev libff
  • Installing rvm
gpg --keyserver hkp:// \
    --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \
\curl -sSL | bash -s stable --ruby=2.5.0 --gems=rails

If you want to skip fetching documentation when installing gems, do the following:

echo "gem: --no-ri --no-rdoc" > ~/.gemrc
  • Source rvm
  source /home/deploy/.rvm/scripts/rvm
  rvm use 2.5.0

Install MySQL

sudo apt-get install mysql-server mysql-client libmysqlclient-dev
  • Setup a password for root while its installing
  • Create environment variables for database
  sudo nano .bashrc

   ## Add following lines. at the end of .bashrc file
   ## Insert your password for m

   export DATABASE_HOST=localhost
   export DATABASE_USER=root
   export DATABASE_PASS=Bilal-IS-Awesome
  • Source the bashrc file
source ~/.bashrc

Install Redis

Be sure to install the latest stable Redis, as the package in the distro may be a bit old:

sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get install redis-server

Install RabbitMQ

  • Download Erlang

  • Install using gdebi

  sudo apt install gdebi
  sudo gdebi esl-erlang_20.1-1~ubuntu~xenial_amd64.deb
  • Install RabbitMQ
echo "deb xenial main" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list
wget -O- | sudo apt-key add -

sudo apt-get update
sudo apt-get install rabbitmq-server

sudo rabbitmq-plugins enable rabbitmq_management
sudo service rabbitmq-server restart
wget http://localhost:15672/cli/rabbitmqadmin
chmod +x rabbitmqadmin
sudo mv rabbitmqadmin /usr/local/sbin

Install Bitcoind

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoind

Configuring Bitcoind

  • Prepare config files:
mkdir -p ~/.bitcoin
touch ~/.bitcoin/bitcoin.conf
sudo nano ~/.bitcoin/bitcoin.conf
  • Insert the following lines into bitcoin.conf, and replace with your username and password.

# If run on the test network instead of the real bitcoin network
# testnet=1

# You must set rpcuser and rpcpassword to secure the JSON-RPC api
# Please make rpcpassword to something secure, `5gKAgrJv8CQr2CGUhjVbBFLSj29HnE6YGXvfykHJzS3k` for example.
# Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)

# Notify when receiving coins
walletnotify=/usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "currency":"btc"}'
  • Start bitcoin daemon:

Installing Nginx & Passenger

  • Install Phusion’s PGP key to verify packages
  sudo apt-get install -y dirmngr gnupg
  sudo apt-key adv --keyserver --recv-keys 561F9B9CAC40B2F7
  • Add HTTPS support to APT
sudo apt-get install apt-transport-https ca-certificates
  • Add the passenger repository.

Note that this only works for Ubuntu 16.04. For other versions of Ubuntu, you have to add the appropriate repository according to Section 2.3.1 of this link.

sudo add-apt-repository 'deb xenial main'
sudo apt-get update
  • Install nginx and passenger
  sudo apt-get install nginx-extras passenger
  • Next, we need to update the Nginx configuration to point Passenger to the version of Ruby that we’re using. You’ll want to open up /etc/nginx/nginx.conf in your favorite editor,
sudo nano /etc/nginx/passenger.conf
  • Find the following lines, and update them with these:
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/.rvm/rubies/ruby-2.5.0/bin/ruby;
  • Enable to include this file in nginx
sudo nano /etc/nginx/nginx.conf
  • Find this line and uncomment it :)
include /etc/nginx/passenger.conf;
  • Install JavaScript Runtime A JavaScript Runtime is needed for Asset Pipeline to work. Any runtime will do but Node.js is recommended.
  curl -sL | sudo bash -
  sudo apt-get install nodejs
  • Then install and run yarn:
sudo apt-get install gcc g++ make
curl -sL | sudo apt-key add -
echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

9. Install ImageMagick

sudo apt-get install imagemagick

Configure Peatio

  • Setup production environment variable
    • Setting up production environment
  echo "export RAILS_ENV=production" >> ~/.bashrc
  • Clone the project:
git clone peatio
cd peatio
git checkout 1-8-stable  // Choose your version, but make sure you'll install the same version for peatio-trading-ui
bundle install
  • Creating and Sourcing Secret_key_base
bundle exec rake secret
echo "export SECRET_KEY_BASE=YOUR-SECRET" >> ~/.bashrc
source ~/.bashrc
  • Install ruby-dev
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt update
sudo apt-get install ruby2.5 ruby2.5-dev
sudo apt upgrade
  • Run setup
  • Setup Pusher Peatio depends on pusher. A development key/secret pair for development/test is provided in config/application.yml.


  1.  Create an account on
  2.  Create an app
  3.  Set pusher-related settings
sudo nano config/application.yml
  • Setup bitcoind rpc endpoint
  sudo nano config/seed/currencies.yml
  • Replace username:pass and port
  json_rpc_endpoint: http://deployuser:[email protected]:8332
  • Run daemons Make sure you are in /peatio directory
god -c lib/daemons/daemons.god

Setup the Google Authentication

By default, it ask for Google Authentication. This parameter can be changed in /config/application.yml

  • Setup a new Web application on Configure the Google Id, Secret and callback in
sudo nano config/application.yml

Note: Make sure your host ISN’T an IP in the callback config. Looks like Google auth expect a callback to a DNS only

  GOOGLE_CLIENT_ID: <Google id>
  GOOGLE_CLIENT_SECRET: <Google secret>
  • Setup Auth0

Change OAUTH2. This parameter can be changed in /config/application.yml ->

  • Setup a new Web application on
  sudo nano config/application.yml
  • Insert values

Run Peatio

Finalize the config; open /config/application.yml Set the DNS of your host (IP won’t work if you use Google Authentication)

sudo nano config/application.yml

Start the server:

bundle exec rails server
OR Make sure the port 3000 is open your server Start the server by passing the ip in parameter
bundle exec rails server -b

You can also provide a port

bundle exec rails server -p 3000

Validate the server is working:

Install nginx to setup a reverse proxy

        sudo apt-get update
        sudo apt-get install nginx
        sudo ufw allow 'Nginx HTTP'
        systemctl status nginx

At this point you should see nginx running. But you need to edit the default config to setup the reverse proxy. Open /etc/nginx/sites-available/default in your favorite editor Replace the content of the file by the following

        server {
          listen      80 default_server;

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

          location / {

Generate JWT key-pair

ruby -e "require 'openssl'; require 'base64'; OpenSSL::PKey::RSA.generate(2048).tap { |p| puts '', 'PRIVATE RSA KEY (URL-safe Base64 encoded, PEM):', '', Base64.urlsafe_encode64(p.to_pem), '', 'PUBLIC RSA KEY (URL-safe Base64 encoded, PEM):', '', Base64.urlsafe_encode64(p.public_key.to_pem) }"