Donate VRC/VRM for the Wiki to VBzaNDExHyFpnNvYc5QH5e4ipBZqxxPnKJ . Thank you, Joe.

Difference between revisions of "Setting up a Verium Mining Pool"

From VeriCoin & Verium Wiki
Jump to: navigation, search
m (Added blurb about not skipping MySQL 5.6 patch.)
m (Setup User & Install: Add a sed command instead of having to manually modify with editor)
Line 363: Line 363:
 
cd nomp</nowiki>
 
cd nomp</nowiki>
  
You will need to make yet another weird change. In line 46 of the file '''''package.json''''', the entry  ''''' "request": "*", ''''' needs to be changed to ''''' "request": "2.69.0", ''''':
+
You will need to make yet another weird change. In line 46 of the file '''''package.json''''', the entry  ''''' "request": "*", ''''' needs to be changed to ''''' "request": "2.69.0", '''''.
 +
 
 +
If you want to be fancy make the change in one sweep with:
 +
 
 +
<nowiki>
 +
sed -i 's/"request": "\*",/"request": "2.69.0",/g' package.json</nowiki>
 +
 
 +
Otherwise, do it in an editor:
  
 
  <nowiki>
 
  <nowiki>

Revision as of 05:39, 13 January 2018

This guide should give you some hints on how to set up a mining pool for Verium.

STILL WIP - COMING SOON!!!

Overview

This guide will help you get started with setting up your first mining pool. Consider this guide more of a "How to setup a Proof of Concept (PoC) mining pool" rather than a pool ready for public use.

If you are thinking about setting up a public VRM mining pool for fun and profit, make sure you understand that pool operation is a commitment not to be taken lightly and will probably require a considerable investment of time and money on your part. Also, do not do a disservice to your loyal miners by deploying a soup sandwich mining pool. We are all learning and nobody is perfect but do your best to make sure your miners and their hard earned VRM coins are safe and secure.

Ubuntu Mining Pool POC

The commands in this guide were run on an updated Ubuntu 16.04 LTS server on AWS.

Update & Upgrade

With the root account or sudo, run these commands:

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get upgrade -yq
apt-get dist-upgrade -f -y

Install VRM Wallet Dependencies

You will need the following packages installed in order to install the VRM wallet software on Ubuntu. Install using the root account or sudo:

apt install libminizip-dev libcurl4-openssl-dev unzip libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev libqrencode-dev freeglut3-dev git build-essential automake autoconf pkg-config libcurl4-openssl-dev libjansson-dev libssl-dev libgmp-dev -y

Install NOMP Dependencies

You will need the following packages to run NOMP stratum software [1]. Install using the root account or sudo:

apt install git build-essential libssl-dev npm nodejs nodejs-legacy -y

Install MPOS Dependencies

The following packages are required for the frontend software called MPOS and is explained here [2]. Note however that the commands below use more recent packages. If you have been following along, all of these packages will already be installed but if not, install using the root account or sudo:

apt install build-essential autoconf libtool libboost-all-dev libcurl4-openssl-dev libdb5.3-dev libdb5.3++-dev -y

Install MySQL & Setup a DB User

The frontend MPOS software uses MySQL to store data. However, MPOS is not 100% compatible with MySQL 5.7 per the project's FAQ [3]. For now, use the Linux root account or sudo to setup a MySQL database server and MySQL root account:

export DB_ROOT_PASS=<strong password>

export DEBIAN_FRONTEND="noninteractive"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DB_ROOT_PASS"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DB_ROOT_PASS"
apt install mysql-server -y 

Per the above linked FAQ, edit the 'my.cnf' file to make the recommended workaround persistent:

First edit the file:

vi /etc/mysql/my.cnf

Then add the following line. DO NOT SKIP this step because MySQL 5.7 does not work and will cause problems with shares being credited. See here for background [4].

[mysqld]
!sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

The my.cnf file should look like this when you are done:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

[mysqld]
!sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

Next restart the MySQL server:

/etc/init.d/mysql restart

Now apply some security to your new and shiny MySQL server:

mysql_secure_installation

Here is an example output of running the above command:

root@ip-x-x-x-x:/home/ubuntu# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y

New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 

Finally, add a user for the MPOS frontend software. Do not run MPOS using the root MySQL DB account.

Connect to your MySQL server:

mysql -u root -p

And then create a user. This example grants ALL and should be locked down even more if possible:

GRANT ALL PRIVILEGES ON *.* TO 'yourMPOSDBusername'@'localhost' IDENTIFIED BY 'yourMPOSDBusersecurepassword';

Confirm that you can login using the new account and list all MySQL DB users. Here is an example:

root@ip-x-x-x-x:/home/ubuntu# mysql -u NewSexyUser -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user from mysql.user;
+------------------+
| user             |
+------------------+
| NewSexyUser      |
| debian-sys-maint |
| mysql.session    |
| mysql.sys        |
| root             |
+------------------+
5 rows in set (0.00 sec)

mysql> exit
Bye

MySQL DB Security Considerations

Database security can be a job in itself. There are many things to consider, here are a few...

  • Avoid running DB on the same server as the Webserver and Wallet software. Segmentation goes a long way.
  • Make sure to not only make back ups, but make sure to test said backups.
  • Monitor your DB regularly for anything whacky.

Wallet Install & RPC Setup

DJoeDt at Github has scripts available to quickly get started here: [5]

The following code snippet is an example using pieces of DJoeDt's install_Verium_Wallet.sh script. The biggest difference is running the wallet daemon as a limited Linux user instead of root. Make sure the above mentioned dependencies have been installed before running these commands.

As root or an account with sudo, create a user account that will run the veriumd daemon:

export LINUX_OS_WALLET_USER=<username>
useradd -m -r $LINUX_OS_WALLET_USER

Now, login to the account and change directory to the account's home folder:

su $LINUX_OS_WALLET_USER
cd ~<nowiki>

The following commands will setup your VRM wallet for the mining pool:

 <nowiki>
export WALLET_RPC_PORT=33987
export WALLET_RPC_USER=<wallet rpc user>
export WALLET_RPC_PASS=<wallet rpc user password>
# Only set this if you need an additional IP range besides localhost and 127.0.0.1
export WALLET_RPC_ALLOW_IP=

mkdir ~/verium
git clone https://github.com/VeriumReserve/verium ~/verium/wallet
cd ~/verium/wallet/src
make -f makefile.unix
wget https://www.vericoin.info/downloads/verium.conf
echo " " >> ~/verium/wallet/src/verium.conf
echo "server=1" >> ~/verium/wallet/src/verium.conf
echo "listen=1" >> ~/verium/wallet/src/verium.conf
echo "daemon=1" >> ~/verium/wallet/src/verium.conf
echo "gen=0" >> ~/verium/wallet/src/verium.conf
echo "rpcuser=$WALLET_RPC_USER" >> ~/verium/wallet/src/verium.conf
echo "rpcpassword=$WALLET_RPC_PASS" >> ~/verium/wallet/src/verium.conf
echo "rpcallowip=127.0.0.1" >> ~/verium/wallet/src/verium.conf
echo "rpcallowip=localhost" >> ~/verium/wallet/src/verium.conf
echo "rpcallowip=$WALLET_RPC_ALLOW_IP" >> ~/verium/wallet/src/verium.conf
echo "rpcport=$WALLET_RPC_PORT" >> ~/verium/wallet/src/verium.conf
~/verium/wallet/src/veriumd
sleep 60
./veriumd bootstrap false
~/verium/wallet/src/veriumd
sleep 120

exit

Once the wallet is installed, bootstrapped, and running, you can run several commands to make sure things are in order:

Get a list of RPC commands available:

./veriumd help

Linux OS command to verify that the veriumd daemon is running:

ps aux | grep veriumd

Ensure that the wallet is connected to the network and working correctly.

./veriumd getinfo

Get the wallet address.

./veriumd getaddressesbyaccount ""

If you wanted to use the wallet address in a script, you could store it in a variable:

export WALLETADDRESS=$(/home/$VRM_WALLET_OS_USER/verium/wallet/src/veriumd getaddressesbyaccount "" | awk '/"/ {print $1;}' | cut -d\" -f2)

Wallet Security Consideration

This is not an exclusive list of considerations...

  • According to this issue [6], it appears that MPOS does not work with encrypted wallets.
  • Avoid running the wallet daemon on the same server (i.e. web server) exposed to the public Internet.
  • Configuring rpcssl=1 as well as certificates could improve security for the wallet verium.conf file. Not much added security value if all run on the same server but if making connections from different servers, encrypts RPC communications and adds an extra layer of security.
  • Avoid running wallet software on same server running DB and Webserver; in other words, take measures to guard this like an actual bank vault.

Redis Install

This is probably the easiest part of this PoC setup.

First using the root account or sudo, install Redis

apt install redis-server -y

And make sure the Redis daemon is running:

ps aux | grep redis

NOMP Install & Configuration

Now is the part that can be a complete pain if you've never installed NOMP before. Actually, its uncertain if this is even the correct, much less the "best" way to install NOMP but it works.

Setup User & Install

First, setup another Linux OS user that will run the NOMP stratum daemon. Do not run the daemon as root.

export STRATUM_OS_USER=<yournompstratumusername>

## -m = create home folder -r = create system user
useradd -m -r $STRATUM_OS_USER

Next, login to the newly created account and change directory to the home folder:

su $STRATUM_OS_USER
cd ~

NOMP will ONLY work with node v0.10+ as mentioned here [7].

curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
source ~/.profile
nvm install 0.10.25
nvm use 0.10.25
nvm alias default 0.10.25

Now we can finally download NOMP:

git clone https://github.com/zone117x/node-open-mining-portal nomp
cd nomp

You will need to make yet another weird change. In line 46 of the file package.json, the entry "request": "*", needs to be changed to "request": "2.69.0", .

If you want to be fancy make the change in one sweep with:

sed -i 's/"request": "\*",/"request": "2.69.0",/g' package.json

Otherwise, do it in an editor:

vi package.json

The file should like like this:

{
    "name": "node-open-mining-portal",
    "version": "0.0.4",
    "description": "An extremely efficient, highly scalable, all-in-one, easy to setup cryptocurrency mining pool",
    "keywords": [
        "stratum",
        "mining",
        "pool",
        "server",
        "poolserver",
        "bitcoin",
        "litecoin",
        "scrypt"
    ],
    "homepage": "https://github.com/zone117x/node-open-mining-portal",
    "bugs": {
        "url": "https://github.com/zone117x/node-open-mining-portal/issues"
    },
    "license": "GPL-2.0",
    "author": "Matthew Little",
    "contributors": [
        "vekexasia",
        "TheSeven"
    ],
    "main": "init.js",
    "bin": {
        "block-notify": "./scripts/blockNotify.js"
    },
    "repository": {
        "type": "git",
        "url": "https://github.com/zone117x/node-open-mining-portal.git"
    },
    "dependencies": {
        "stratum-pool": "git://github.com/zone117x/node-stratum-pool.git",
        "dateformat": "1.0.12",
        "node-json-minify": "*",
        "redis": "0.12.1",
        "mysql": "*",
        "async": "1.5.2",
        "express": "*",
        "body-parser": "*",
        "compression": "*",
        "dot": "*",
        "colors": "*",
        "node-watch": "*",
        "request": "2.69.0",
        "nonce": "*",
        "bignum": "0.12.5",
        "extend": "*"
    },
    "engines": {
        "node": ">=0.10"
    }
}

After you have made the change and saved the file, take a deep breath and run the following command:

npm update

If everything went well, the last six lines of the output should look similar to this:

.
.
.
make: Leaving directory '/home/stratumuser/nomp/node_modules/stratum-pool/node_modules/multi-hashing/build'
[email protected] node_modules/stratum-pool
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

Frontend & Coin Configuration

Make sure you are still logged with the Linux OS account that will run the NOMP stratum daemon and still in the NOMP folder:

yournompstratumusername@ip-x-x-x-x:~/nomp$ pwd
/home/yournompstratumusername/nomp

From here you need to copy the example JSON file to a file called config.json and then edit it:

cp config_example.json config.json
vi config.json

THIS NEEDS TO BE CONFIRMED!!!

Change the website entry line (Line 33) from "true" to "false". This tells NOMP to not use NOMP's frontend so that the MPOS frontend can be used.

config.json should like like this when you are done:

{
    "logLevel": "debug",
    "logColors": true,

    "cliPort": 17117,

    "clustering": {
        "enabled": true,
        "forks": "auto"
    },

    "defaultPoolConfigs": {
        "blockRefreshInterval": 1000,
        "jobRebroadcastTimeout": 55,
        "connectionTimeout": 600,
        "emitInvalidBlockHashes": false,
        "validateWorkerUsername": true,
        "tcpProxyProtocol": false,
        "banning": {
            "enabled": true,
            "time": 600,
            "invalidPercent": 50,
            "checkThreshold": 500,
            "purgeInterval": 300
        },
        "redis": {
            "host": "127.0.0.1",
            "port": 6379
        }
    },

    "website": {
        "enabled": false,
        "host": "0.0.0.0",
        "port": 80,
        "stratumHost": "cryppit.com",
        "stats": {
            "updateInterval": 60,
            "historicalRetention": 43200,
            "hashrateWindow": 300
        },
        "adminCenter": {
            "enabled": true,
            "password": "password"
        }
    },

    "redis": {
        "host": "127.0.0.1",
        "port": 6379
    },

    "switching": {
        "switch1": {
            "enabled": false,
            "algorithm": "sha256",
            "ports": {
                "3333": {
                    "diff": 10,
                    "varDiff": {
                        "minDiff": 16,
                        "maxDiff": 512,
                        "targetTime": 15,
                        "retargetTime": 90,
                        "variancePercent": 30
                    }
                }
            }
        },
        "switch2": {
            "enabled": false,
            "algorithm": "scrypt",
            "ports": {
                "4444": {
                    "diff": 10,
                    "varDiff": {
                        "minDiff": 16,
                        "maxDiff": 512,
                        "targetTime": 15,
                        "retargetTime": 90,
                        "variancePercent": 30
                    }
                }
            }
        },
        "switch3": {
            "enabled": false,
            "algorithm": "x11",
            "ports": {
                "5555": {
                    "diff": 0.001,
                    "varDiff": {
                        "minDiff": 0.001,
                        "maxDiff": 1, 
                        "targetTime": 15, 
                        "retargetTime": 60, 
                        "variancePercent": 30 
                    }
                }
            }
        }
    },

    "profitSwitch": {
        "enabled": false,
        "updateInterval": 600,
        "depth": 0.90,
        "usePoloniex": true,
        "useCryptsy": true,
        "useMintpal": true,
        "useBittrex": true
    }
}

Next, we need to make a coin configuration. Let's call the new coin file, verium.json:

cp coins/vertcoin.json coins/verium.json
vi coins/verium.json

THIS NEEDS TO BE CONFIRMED!!!

Your verium.json coin file should now look like this:

{
    "name": "Verium",
    "symbol": "VRM",
    "algorithm": "scrypt-n",
    "timeTable": {
      "1048576": 100
    }
}

Stratum Pool Configuration

THIS NEEDS TO BE CONFIRMED!!! ESPECIALLY BEST PORTS AND DIFFICULTY SETTINGS + RATIONALE!!!

Now it's time to setup the stratum pool.

cp pool_configs/litecoin_example.json pool_configs/verium.json
vi pool_configs/verium.json

There are various configurations in this file, namely the ports and difficulty settings. Note that in the last entry in the sample configuration below, "mposMode" is where we tell NOMP to use MPOS for the front end and store data in the MySQL database. Up to this point, we have configured the database server, but not an actual database for NOMP and MPOS to use. Consider using a different database name from the default.

Your final pool config verium.json should look similar to this:

{
    "enabled": true,
    "coin": "verium.json",

    "address": "YourPoolWalletVRMAddress",

    "paymentProcessing": {
        "enabled": false,
        "paymentInterval": 20,
        "minimumPayment": 70,
        "daemon": {
            "host": "127.0.0.1",
            "port": 19332,
            "user": "testuser",
            "password": "testpass"
        }
    },

    "ports": {
        "3332": {
            "diff": 0.001,
            "varDiff": {
              "minDiff": 0.001,
              "maxDiff": 0.03,
              "targetTime": 100,
              "retargetTime": 90,
              "variancePercent": 30
            
            }
        },
        "3333": {
            "diff": 0.03,
            "varDiff": {
                "minDiff": 0.03,
                "maxDiff": 0.2,
                "targetTime": 100,
                "retargetTime": 90,
                "variancePercent": 30
            }
        },
        "3334": {
            "diff": 0.2,
            "varDiff": {
                "minDiff": 0.02,
                "maxDiff": 0.06,
                "targetTime": 100,
                "retargetTime": 90,
                "variancePercent": 30
            }
        }
    },

    "daemons": [
        {
            "host": "127.0.0.1",
            "port": 33987,
            "user": "<wallet rpc user>",
            "password": "<wallet rpc user>"
        }
    ],

    "p2p": {
        "enabled": false,
        "host": "127.0.0.1",
        "port": 19333,
        "disableTransactions": true
    },

    "mposMode": {
        "enabled": true,
        "host": "127.0.0.1",
        "port": 3306,
        "user": "yourMPOSDBusername",
        "password": "yourMPOSDBusersecurepassword",
        "database": "mpos",
        "checkPassword": true,
        "autoCreateWorker": false
    }

}

At this point you can exit out of the Linux OS stratum user account.

MPOS Install & Configuration

Using root or sudo, install the following dependencies required for MPOS as outlined at [8]. Note however that the commands below are updated and different from what the MPOS wiki explains.

apt install memcached php-memcached php-mysqlnd php-curl php-json libapache2-mod-php -y

Next, use the following commands to download MPOS:

cd /var/www
sudo git clone git://github.com/MPOS/php-mpos.git MPOS
cd MPOS
git checkout master

Make sure you are in the MPOS folder. If you aren't sure, use the pwd command:

root@ip-x-x-x-x:/var/www/MPOS# pwd
/var/www/MPOS

Change ownership of the folders templates/compile, templates/cache, and logs as explained at [9]:

chown -R www-data templates/compile templates/cache logs 

Now it's time to create the database using the database user that you configured in the section: Install MySQL & Setup a DB User. In the snippet below, we are using the default database name of mpos:

mysql -u <nonrootDBuser> -p -e "create database mpos"
mysql -u <nonrootDBuser> -p mpos < sql/000_base_structure.sql

The following commands will copy a template and edit it:

cp include/config/global.inc.dist.php include/config/global.inc.php
vi include/config/global.inc.php

Here is a sample global.inc.php configuration. More detailed settings, configurations, and explanations will be outlined in section Link title.

<?php
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;

/**
 * Do not edit this unless you have confirmed that your config has been updated!
 * Also the URL to check for the most recent upstream versions available
 *  https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-config-version
 **/
$config['version'] = '1.0.1';
$config['version_url'] = 'https://raw.githubusercontent.com/MPOS/php-mpos/master/include/version.inc.php';

/**
 * Unless you disable this, we'll do a quick check on your config first.
 *  https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-config-check
 */
$config['skip_config_tests'] = false;

/**
 * Unless you disable this, we'll do a check for a valid coin address on registration.
 *  https://github.com/MPOS/php-mpos/wiki/Config-Setup#check-for-valid-wallet-address
 */
$config['check_valid_coinaddress'] = true;

/**
 * Defines
 *  Debug setting and salts for hashing passwords
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-defines--salts
 */
$config['DEBUG'] = 0;
$config['SALT'] = 'SetAtLeast30RandomCharactersHere';
$config['SALTY'] = 'SetAtLeast30RandomCharactersHere';

/**
  * Coin Algorithm
  *  Algorithm used by this coin, sha256d or scrypt
  *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-algorithm
  **/
$config['algorithm'] = 'scryptn';

/**
  * Getbalance API Calls
  *  System used for getting actual Balance from Wallet
  *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#getbalance-api-calls
  **/
$config['getbalancewithunconfirmed'] = false;

/**
 * Database configuration
 *  MySQL database configuration
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-database-configuration
 **/
$config['db']['host'] = 'localhost';
$config['db']['user'] = 'nonrootDBuser';
$config['db']['pass'] = 'nonrootDBuserpassword';
$config['db']['port'] = 3306;
$config['db']['name'] = 'mpos';
// Disabled by default and set in bootstrap if unset, but left in here so
// people know it exists
// $config['db']['shared']['accounts'] = $config['db']['name'];
// $config['db']['shared']['workers'] = $config['db']['name'];
// $config['db']['shared']['news'] = $config['db']['name'];

/**
 * Local wallet RPC
 *  RPC configuration for your daemon/wallet
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-local-wallet-rpc
 **/
$config['wallet']['type'] = 'http';
$config['wallet']['host'] = 'localhost:33987';
$config['wallet']['username'] = 'WALLET_RPC_USER';
$config['wallet']['password'] = 'WALLET_RPC_PASS';

/**
 * Swiftmailer configuration
 *  Configure your way to send mails
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-swiftmailer
 **/
$config['swiftmailer']['type'] = 'sendmail';
$config['swiftmailer']['sendmail']['path'] = '/usr/sbin/sendmail';
$config['swiftmailer']['sendmail']['options'] = '-bs';
$config['swiftmailer']['smtp']['host'] = 'your.mail-relay.com';
$config['swiftmailer']['smtp']['port'] = '587';
$config['swiftmailer']['smtp']['encryption'] = 'tls';
$config['swiftmailer']['smtp']['username'] = '';
$config['swiftmailer']['smtp']['password'] = '';
$config['swiftmailer']['smtp']['throttle'] = 100;

/**
 * Getting Started Config
 *  Shown to users in the 'Getting Started' section
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-getting-started
 **/
$config['gettingstarted']['coinname'] = 'Verium';
$config['gettingstarted']['coinurl'] = 'https://portal.vericoin.info/';
$config['gettingstarted']['stratumurl'] = 'yourdomain.com';
$config['gettingstarted']['stratumport'] = '3333';

/**
 * Ticker API
 *  Fetch exchange rates via an API
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-ticker-api
 **/
$config['price']['enabled'] = false;
$config['price']['url'] = 'https://btc-e.com';
$config['price']['target'] = '/api/2/ltc_usd/ticker';
$config['price']['currency'] = 'USD';

/**
 * Automatic Payout Thresholds
 *  Minimum and Maximum auto payout amount
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-automatic-payout-thresholds
 **/
$config['ap_threshold']['min'] = 2;
$config['ap_threshold']['max'] = 20;

/**
 * Minimum manual Payout Threshold
 *  Minimum manual payout amount
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-manual-payout-threshold
 **/
$config['mp_threshold'] = 1;

/**
 * Donation thresholds
 *  Minimum donation amount in percent
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-donation-thresholds
 **/
$config['donate_threshold']['min'] = 1;

/**
 * Account Specific Settings
 *  Settings for each user account
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-account-specific-settings
 **/
$config['accounts']['invitations']['count'] = 5;

/**
 * Currency
 *  Shorthand name for the currency
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-currency
 */
$config['currency'] = 'VRM';

/**
 * Coin Target
 *  Target time for coins to be generated
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-coin-target
 **/
$config['cointarget'] = '150';

/**
 * Coin Diff Change
 *  Amount of blocks between difficulty changes
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-coin-diff-change
 **/
$config['coindiffchangetarget'] = 2016;

/**
 * TX Fees
 *  Fees applied to transactions
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-tx-fees
 **/
$config['txfee_auto'] = 0.1;
$config['txfee_manual'] = 0.1;

/**
 * Block & Pool Bonus
 *  Bonus coins for blockfinder or a pool bonus for everyone
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-block-bonus
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pool-bonus
 */
$config['block_bonus'] = 0;
$config['pool_bonus'] = 0;
$config['pool_bonus_type'] = 'payout';

/**
 * Payout System
 *  Payout system chosen
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-payout-system
 **/
$config['payout_system'] = 'prop';

/**
 * Sendmany Support
 *  Enable/Disable Sendmany RPC method
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-sendmany-support
 **/
$config['sendmany']['enabled'] = false;

/**
 * Transaction Limits
 *  Number of transactions per payout run
 **/
$config['payout']['txlimit_manual'] = 500;
$config['payout']['txlimit_auto'] = 500;

/**
 * Round Purging
 *  Round share purging configuration
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-round-purging
 **/
$config['purge']['sleep'] = 1;
$config['purge']['shares'] = 25000;

/**
 * Share Archiving
 *  Share archiving configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-archiving
 **/
$config['archive']['maxrounds'] = 10; 
$config['archive']['maxage'] = 60 * 24; 


/**
 * Pool Fees
 *  Fees applied to users
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pool-fees
 */
$config['fees'] = 0;

/**
 * PPLNS
 *  Pay Per Last N Shares
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pplns-settings
 */
$config['pplns']['shares']['default'] = 4000000;
$config['pplns']['shares']['type'] = 'blockavg';
$config['pplns']['blockavg']['blockcount'] = 10;
$config['pplns']['reverse_payout'] = true;
$config['pplns']['dynamic']['percent'] = 30;

/**
 * Difficulty
 *  Difficulty setting for stratum/pushpool
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pool-target-difficulty
 */
$config['difficulty'] = 20;

/**
 * Block Reward
 *  Block reward configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-reward-settings
 **/
$config['reward_type'] = 'block';
$config['reward'] = 50;

/**
 * Confirmations
 *  Credit and Network confirmation settings
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-confirmations
 */
$config['confirmations'] = 120;
$config['network_confirmations'] = 120;

/**
 * PPS
 *  Pay Per Share configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-pps-settings
 **/
$config['pps']['reward']['default'] = 50;
$config['pps']['reward']['type'] = 'blockavg';
$config['pps']['blockavg']['blockcount'] = 10;

/**
 * Memcache
 *  Memcache configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-memcache
 **/
$config['memcache']['enabled'] = true;
$config['memcache']['host'] = 'localhost';
$config['memcache']['port'] = 11211;
$config['memcache']['keyprefix'] = 'mpos_';
$config['memcache']['expiration'] = 90;
$config['memcache']['splay'] = 15;
$config['memcache']['force']['contrib_shares'] = false;
$config['memcache']['sasl'] = false;
$config['memcache']['sasl']['username'] = '';
$config['memcache']['sasl']['password'] = '';

/**
 * Cookies
 *  Cookie configuration details
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-cookies
 **/
$config['cookie']['duration'] = '1440';
$config['cookie']['domain'] = '';
$config['cookie']['path'] = '/';
$config['cookie']['httponly'] = true;
$config['cookie']['secure'] = false;

/**
 * Smarty Cache
 *  Enable smarty cache and cache length
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-smarty-cache
 **/
$config['smarty']['cache'] = 0;
$config['smarty']['cache_lifetime'] = 30;

/**
 * System load
 *  Disable some calls when high system load
 *   https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-system-load
 **/
$config['system']['load']['max'] = 10.0;

Now it's time to choose a webserver and configure it!

Web Server Configuration

You can use Apache or NGINX for your web server. This PoC will explain both methods.

NGINX Example

The MPOS Wiki has brief guidance on how to setup MPOS with NGINX. This guide will go into much more detail to include TLS setup.

First, we need to remove apache:

systemctl stop apache2


Install the following dependencies using root or sudo:

apt install nginx php-fpm -y
apt remove --purge apache2 -y

Now install NGINX and start it:

apt install nginx -y
systemctl start nginx
systemctl enable nginx

Make sure NGINX is running with command systemctl status nginx. There should be no errors; do not proceed if something went wrong.

Now install the dependency for the Fast CGI module:

apt install php-fpm -y