- Setup deploy user
- Install Ruby
- Install MySQL
- Install Redis
- Install RabbitMQ
- Install Bitcoind
- Install Nginx with Passenger
- Install JavaScript Runtime
- Install ImageMagick
- Configure Peatio
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
Make sure your system is up-to-date.
sudo apt-get update
sudo apt-get upgrade
Installing rbenv using a Installer
sudo apt-get install git-core curl zlib1g-dev build-essential \
libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
Install Ruby 2.1.2 through rbenv:
rbenv install 2.1.2
rbenv global 2.1.2
Install bundler
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
gem install bundler
rbenv rehash
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
Be sure to install the latest stable Redis, as the package in the distro may be a bit old:
sudo apt-add-repository -y ppa:rwky/redis
sudo apt-get update
sudo apt-get install redis-server
Please follow instructions here: https://www.rabbitmq.com/install-debian.html
curl http://www.rabbitmq.com/rabbitmq-signing-key-public.asc | sudo apt-key add -
sudo apt-add-repository 'deb http://www.rabbitmq.com/debian/ testing main'
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
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install bitcoind
Configure
mkdir -p ~/.bitcoin
touch ~/.bitcoin/bitcoin.conf
vim ~/.bitcoin/bitcoin.conf
Insert the following lines into the bitcoin.conf, and replce with your username and password.
server=1
daemon=1
# 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)
rpcuser=INVENT_A_UNIQUE_USERNAME
rpcpassword=INVENT_A_UNIQUE_PASSWORD
rpcport=18332
# Notify when receiving coins
walletnotify=/usr/local/sbin/rabbitmqadmin publish routing_key=peatio.deposit.coin payload='{"txid":"%s", "channel_key":"satoshi"}'
Start bitcoin
bitcoind
Install Phusion's PGP key to verify packages
sudo apt-key adv --keyserver keyserver.ubuntu.com --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 14.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 https://oss-binaries.phusionpassenger.com/apt/passenger trusty 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 vim /etc/nginx/nginx.conf
find the following lines, and uncomment them:
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
update the second line to read:
passenger_ruby /home/deploy/.rbenv/shims/ruby;
A JavaScript Runtime is needed for Asset Pipeline to work. Any runtime will do but Node.js is recommended.
sudo apt-get install nodejs
sudo apt-get install imagemagick
echo "export RAILS_ENV=production" >> ~/.bashrc
source ~/.bashrc
mkdir -p ~/peatio
git clone git://github.com/peatio/peatio.git ~/peatio/current
cd peatio/current
# Install dependency gems
bundle install --without development test --path vendor/bundle
Prepare configure files
bin/init_config
Setup Pusher
- Peatio depends on Pusher. A development key/secret pair for development/test is provided in
config/application.yml
(uncomment to use). PLEASE USE IT IN DEVELOPMENT/TEST ENVIRONMENT ONLY!
More details to visit pusher official website
# uncomment Pusher related settings
vim config/application.yml
Setup bitcoind rpc endpoint
# replace username:password and port with the one you set in
# username and password should only contain letters and numbers, do not use email as username
# bitcoin.conf in previous step
vim config/currencies.yml
Config database settings
vim config/database.yml
# Initialize the database and load the seed data
bundle exec rake db:setup
Precompile assets
bundle exec rake assets:precompile
Run Daemons
# start all daemons
bundle exec rake daemons:start
# or start daemon one by one
bundle exec rake daemon:matching:start
...
# Daemon trade_executor can be run concurrently, e.g. below
# line will start four trade executors, each with its own logfile.
# Default to 1.
TRADE_EXECUTOR=4 rake daemon:trade_executor:start
# You can do the same when you start all daemons:
TRADE_EXECUTOR=4 rake daemons:start
SSL Certificate setting
For security reason, you must setup SSL Certificate for production environment, if your SSL Certificated is been configured, please change the following line at config/environments/production.rb
config.force_ssl = true
Passenger:
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /home/deploy/peatio/current/config/nginx.conf /etc/nginx/conf.d/peatio.conf
sudo service nginx restart
Liability Proof
# Add this rake task to your crontab so it runs regularly
RAILS_ENV=production rake solvency:liability_proof