-
Notifications
You must be signed in to change notification settings - Fork 1k
Quick Start Guide WIP
Update Ubuntu
apt-get update
apt-get dist-upgrade
Setup SWAP
I am setting up a 4GB swap, which may be overkill but it’s the most common swap sized used in most guides so ill keep it at that.
dd if=/dev/zero of=/mnt/myswap.swap bs=1M count=4000
mkswap /mnt/myswap.swap
swapon /mnt/myswap.swap
Now let’s add it into fstab so it’ll activate at boot.
nano /etc/fstab
Add the following line at the end of the file.
/mnt/myswap.swap none swap sw 0 0
Ctrl+O
to save, and Ctrl+X
to exit the nano editor.
Now your swap is setup, you can modify the size in the future if you need more or less.
All these Actions are also downloadable in Script 1 activating the script can be done by the following commands:
chmod +x Pool-install-Batch1-Root
./Pool-install-Batch1-Root
-Install Required Packages
apt-get -y install git
apt-get -y install libboost-all-dev build-essential libcurl4-openssl-dev libdb5.3-dev libdb5.3++-dev mysql-server
Set a MySQL Root Password (different from your Ubuntu root pass!) Install Required Packages for Mining Portal Open Source (MPOS)
apt-add-repository ppa:ondrej/php
apt-get update
apt-get -y install php7.0
apt-get -y install memcached php-memcached php7.0-mysqlnd php7.0-curl php7.0-json php7.0-curl libapache2-mod-php7.0
apt-get -y install php7.0-mbstring php-zip zip php7.0-dom
Let’s get Apache Web Server Going:
apache2ctl -k stop; sleep 2; sudo apache2ctl -k start
You will get a message stating it could not reliably determine your servers domain name, don’t worry about this right now. The web server is still running, just go to your server’s ip (http://youserverip) in chrome
All these Actions are also downloadable in Script 2 Activating the script can be done by the following commands:
chmod +x Pool-install-Batch2-Root
./Pool-install-Batch2-Root
Install Required Packages for NOMP Stratum
curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash –
apt-get -y install nodejs
apt-get -y install npm
npm install forever -g
apt-add-repository ppa:chris-lea/redis-server
apt-get update
apt-get -y install redis-server
All these Actions are also downloadable in Script 3 Activating the script can be done by the following commands:
chmod +x Pool-install-Batch3-Root
./Pool-install-Batch3-Root
Setup Webmin
Webmin is a GUI interface for managing your server.
nano /etc/apt/sources.list
Press the Down Arrow on your keyboard to reach the end, and add these two lines below:
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Press Ctrl+O to save, and exit the nano editor with CTRL+X
Let’s get Webmin’s GPG Key
cd /root wget http://www.webmin.com/jcameron-key.asc apt-key add jcameron-key.asc
Install Webmin
apt-get update apt-get install webmin
Webmin should now be installed, now let’s see if it works. Open your browser and go to https://yourserverip:10000/
If you use a virtal server, make sure port 10000 is open so you can browse it.
Go ahead and login.
Username: root
Password: Your server’s root password
If any updates pop up in webmin, then go ahead and install those updates.
When you entered webmin its time to check the MySql module to see if its activated and if your password is set correct for the next parts.
All these Actions are also downloadeable in Script 4 Activating the script can be done by the following commands:
chmod +x Pool-install-Batch4-Root ./Pool-install-Batch4-Root
Install phpMyAdmin
apt-get install phpmyadmin
Select Apache. You then will be asked to configure a database, hit ok and then put in the password you setup with MySQL earlier.
Now we need to add phpmyadmin to Apache.
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf a2enconf phpmyadmin service apache2 reload
Head to http://yourserverip/phpmyadmin
Login to make sure everything is good.
Username: root
Password: the one you setup earlier
Once you login you will see 3 or 4 default databases on the left hand side. You are good to go. if you have less databases reinstall phpmyadmin databases with this command:
sudo dpkg-reconfigure phpmyadmin
you can also check if you are logged in with the correct user \ rights
If you get a red error message on the bottom of phpmyadmin stating mcrypt is missing then do this:
php5enmod mcrypt service apache2 restart
if you get an error message The mbstring extension is missing. Please check your PHP configuration. then do this:
apt-get install php7.0-mbstring
Log back into phpmyadmin and the mcrypt error should be gone.
All these Actions are also downloadeable in Script 5 Activating the script can be done by the following commands:
chmod +x Pool-install-Batch5-Root ./Pool-install-Batch5-Root Mining Pool Setup
First let’s download some of the pool software on your PC. Yes, you’ll be using git and what not to download it on your server however there is a few files you will want to interact with on your PC.
MPOS: https://github.com/MPOS/php-mpos/archive/master.zip
Extract that somewhere on your PC that you can easily access.
User Setup
You never run things like your coin daemon (wallet), mysql, or other things as root!
Let’s create a user for your mining pool.
Login to ssh using putty as root. \
adduser usernameyouwant
You’ll be prompted for a password, please use a password that is different from your root password. The other info it asks for you can either fill out or just leave blank and hit enter.
Now let’s give that new user sudo access.
usermod -aG sudo usernameyousetup MySQL User and Database Setup
Remember phpmyadmin? Head back to it: http://yourserverip/phpmyadmin
Using the password you setup earlier, login as root.
Head to the “Users” button on the top of the page
Click on “Add user” in the middle of the page.
-Fill in the “User name:” field with any username you’d prefer. I like to name it after the coin I am setting up a pool for. -Then click the button next to “Generate password:” –You can use your own password, but I prefer the generated password since it is very strong. Just remember to write it down somewhere. -Now click the checkbox for “Create database with same name and grant all privileges”
If everything is good, then scroll down a bit and click “Go” in the bottom right of the page. -You should get a success message.
Now let’s import the MPOS database.
Click on your pool username/database you just created in the left side of phpmyadmin.
Once you have clicked on the database, go ahead and click “Import” on the top of the
You will see a “Choose File” button, go ahead and click it and browse to the location you extracted that MPOS we downloaded before to.
Once you navigate to the “php-mpos-master” folder on your computer go ahead and click on the “sql” folder inside. Then click on “000_base_structure.sql” and click open.
That’s all you have to do for settings
Now click “Go” on the bottom of the page. You should get a success message stating your import was successful.
The MySQL user and Database has been successfully setup for your mining pool. Install Postfix maildaemon
There are many reasons why you would want to configure Postfix to send email using an external SMTP provider such as Mandrill, SendGrid, Amazon SES, or any other SMTP server. One reason is to avoid getting your mail flagged as spam if your current server’s IP has been added to a spam list. Configure Postfix to Send Mail Using an External SMTP Server
In this tutorial, you will learn how to install and configure a Postfix server to send email through Mandrill, or SendGrid. PrerequisitesPermalink
Before starting this tutorial, you should have:
Your fully qualified domain name (FQDN)
All updates installed : sudo apt-get update
A valid username and password for the SMTP mail provider, such as Mandrill, or SendGrid
Make sure the libsasl2-modules package is installed and up to date: sudo apt-get install libsasl2-modules
NoteThis guide is written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, you can check our Users and Groups guide. Installing PostfixPermalink
In this section, you will install Postfix and set the domain and hostname.
Install Postfix with the following command: sudo apt-get install postfix
During the installation, a prompt will appear asking for your General type of mail configuration. Select Internet Site.
Enter the fully qualified name of your domain, fqdn.example.com.
Once the installation is finished, open the /etc/postfix/main.cf file with your favorite text editor: sudo nano /etc/postfix/main.cf
Make sure that the myhostname parameter is configured with your server’s FQDN: /etc/postfix/main.cf 1 myhostname = fqdn.example.com
Configuring SMTP Usernames and PasswordsPermalink
Usernames and passwords are generally stored in a file called sasl_passwd in the /etc/postfix/ directory. In this section, you’ll add your external mail provider credentials to this file and to Postfix.
If you want to use Mandrill, or SendGrid as your SMTP provider, you may want to reference the appropriate example while working on this section. For Google Apps and Gmail-specific settings, check out our Configure Postfix to Send Mail Using Gmail and Google Apps on Debian or Ubuntu guide.
Open or create the /etc/postfix/sasl_passwd file, using your favorite text editor: sudo nano /etc/postfix/sasl_passwd
Add your destination (SMTP Host), username, and password in the following format: /etc/postfix/sasl_passwd 1 [mail.isp.example] username:password NoteIf you want to specify a non-default TCP Port (such as 587), then use the following format: /etc/postfix/sasl_passwd 1 [mail.isp.example]:587 username:password
Create the hash db file for Postfix by running the postmap command: sudo postmap /etc/postfix/sasl_passwd
If all went well, you should have a new file named sasl_passwd.db in the /etc/postfix/ directory. Securing Your Password and Hash Database FilesPermalink
The /etc/postfix/sasl_passwd and the /etc/postfix/sasl_passwd.db files created in the previous steps contain your SMTP credentials in plain text.
For security reasons, you should change their permissions so that only the root user can read or write to the file. Run the following commands to change the ownership to root and update the permissions for the two files:
sudo chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
Configuring the Relay ServerPermalink
In this section, you will configure the /etc/postfix/main.cf file to use the external SMTP server.
Open the /etc/postfix/main.cf file with your favorite text editor: sudo nano /etc/postfix/main.cf
Update the relayhost parameter to show your external SMTP relay host. Important: If you specified a non-default TCP port in the sasl_passwd file, then you must use the same port when configuring the relayhost parameter. /etc/postfix/main.cf
# specify SMTP relay
host relayhost = [mail.isp.example]:587
NoteCheck the appropriate Google Apps, Mandrill, or SendGrid section for the details to enter here.
At the end of the file, add the following parameters to enable authentication: /etc/postfix/main.cf
# enable SASL authentication smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication.
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
Save your changes.
Restart Postfix: sudo service postfix restart
Testing PostfixPermalink
The fastest way to test your configuration is to send an email to any unrelated email address, using the mail command:
echo "body of your email" | mail -s "This is a Subject" -a "From: [email protected]" [email protected]
You may have to install mailutils to use the mail command:
sudo apt-get install mailutils
Alternatively, you can use Postfix’s own sendmail implementation, by entering lines similar to those shown below:
sendmail [email protected] From: [email protected] Subject: Test mail This is a test email .
Examples of Postfix Configurations with Different ProvidersPermalink
This section shows you settings for some popular mail services you can use as external SMTP servers. You may have to do some fine-tuning on your own to avoid Postfix logins being flagged as suspicious. Settings for MandrillPermalink
Use these settings for Mandrill.
For /etc/postfix/sasl_passwd, use the following configuration with your own credentials: /etc/postfix/sasl_passwd 1 [smtp.mandrillapp.com]:587 USERNAME:API_KEY
For /etc/postfix/main.cf, use the following relayhost: /etc/postfix/main.cf 1 relayhost = [smtp.mandrillapp.com]:587
Create the hash db file for Postfix by running the postmap command: sudo postmap /etc/postfix/sasl_passwd
Restart Postfix: sudo service postfix restart
Settings for SendGridPermalink
Use these settings for SendGrid.
For /etc/postfix/sasl_passwd, use the following configuration with your own credentials: /etc/postfix/sasl_passwd 1 [smtp.sendgrid.net]:587 USERNAME:PASSWORD
For /etc/postfix/main.cf, use the following relayhost: /etc/postfix/main.cf 1 relayhost = [smtp.sendgrid.net]:587
Create the hash db file for Postfix by running the postmap command: sudo postmap /etc/postfix/sasl_passwd
Restart Postfix: sudo service postfix restart
Litecoin Daemon Setup (Wallet)
Now let’s setup the coin daemon, I will be using litecoin.
Now boot up putty and login to that new user we setup earlier.
We download a prebuilt version Litecoin from there offilcail site here: https://download.litecoin.org/litecoin-0.14.2/linux/litecoin-0.14.2-x86_64-linux-gnu.tar.gz
cd wget https://download.litecoin.org/litecoin-0.14.2/linux/litecoin-0.14.2-x86_64-linux-gnu.tar.gz tar -xzf litecoin* cd litecoin* cd bin ls
After issuing “ls” you will see that litecoind and litecoin-cli are in the bin directory. ./litecoind
You will get a message stating there is no configuration file, and they suggest such and such rpc user/pass. We are getting to that.
Now we need to setup the config file for the litecoind.
I am going to start using WinSCP to edit/add files, yes you can use nano, gedit, vim, or whatever shell based text editor you want instead. However, when a novice starts editing as many files as we are about to edit it will be easier for them if they use graphic interface for all of it. It will also help a novice understand the file structure better.
You can get WinSCP here: http://winscp.net/eng/download.php
I will walk you through WinSCP with this litecoind config file, but after that you should be able to use it easily if I just list out what directory you need to go to. You will see here shortly.
Once you install WinSCP, you should be prompted with a login screen.
Select “New Site”
“File Protocol” will be SFTP
“Hostname:” is your VPS IP
“Port number” is your ssh port that you have been using with putty
“User name:” will be root
“Password:” is your root password
Click login, make sure to accept the host key.
Now that you have logged in, you are in the /root folder. Double click the “..” to back out of it.
The file path is /home/username/.litecoin
Click on the “home” folder.
Click on the folder that is named after your username.
Click on “.litecoin” it will be grayed out like
Right click on the white area in WinSCP and Go to “New” and “File”. Should look
Name the file “litecoin.conf”
A white text editor window should pop up, this is WinSCP’s internal editor and what we will be using to edit files. Now we’ll want to put some basic stuff into the configuration file. You should definitely use a different username and password then that I use in the guide. I am just using the ones that litecoind generated for me already.
rpcuser=litecoinrpc
rpcpassword= wdYMsDT4E61jCv8xx6zZd6PYF3iZkjD7t3NpuiGpn6X
rpcallowip=127.0.0.1
rpcport=3000
daemon=1
server=1
gen=0
The default listen port for litecoin is 9333.
Now that you have updated the litecoin.conf file, go ahead and click on the floppy disk icon in the top left of the WinSCP Editor.
Now that we have setup and saved the config file, let’s get back into ssh (putty) on your user that you created earlier.
cd cd litecoin* cd bin ./litecoind
You should get a message that states “Litecoin server starting” if for some reason you can’t get out of that command simply press Ctrl+C in putty and it’ll fix it.
Now let’s make sure it’s updating.
./litecoin-cli getinfo
The wallet should be fully updated by the time this guide is over, however if you are quick or unsure simply run the getinfo command again and compare the block number to http://explorer.litecoin.net/ if the block number matches what’s on that site then you are good to go.
Now let us set the crontab so that the litecoin daemon (litecoind) will always start on boot.
crontab -e
Select “2. /bin/nano <—- easiest”
Use your arrow keys to scroll down to the bottom of the crontab.
Add this line below the # symbols.
@reboot ./litecoin/src/litecoind
Press Ctrl + O to save and Ctrl + X to exit
The Litecoin daemon will now start on boot.
Last thing we need to do is get a new address for our litecoin wallet.
./litecoin-cli getnewaddress
An address will show up, please keep record of this address. We will be using it later in the guide.
Because of the different coins possible we did not script the coin part, use your own coin of choice for install NOMP Stratum Setup
Next we’ll be setting up NOMP (node open mining portal) to be used as a stratum server. NOMP has it’s own front end, but we are using MPOS as the front end instead. Keep following the guide, you will see.
Get on your user (not root) on ssh (putty).
cd
The command we just did, “cd” by default put’s your user in it’s home folder (/home/username), where we will be installing a lot of stuff.
Let’s download NOMP and put it in a directory called nomp. git
clone https://github.com/zone117x/node-open-mining-portal nomp
Let’s go into the nomp directory now.
cd nomp
Let’s update nomp, it may take awhile depending on your servers internet connection. npm update
Now we will create a real config file for nomp.
cp config_example.json config.json
Alright, now you need to boot up WinSCP again and login. Navigate to the nomp directory, which is
/home/username/nomp
If you are still logged into WinSCP from before, you may need to right click and click on refresh in order to see the nomp directory.
You’ll see the config.json, right click on it and edit. Scroll down to where you see:
“website”: {
“enabled”: true,
You need to change the “true” to false. Should look like this when you are done:
Now you can save it and exit out of that config.json a, but we are still using WinSCP so keep it open.
Alright, now NOMP needs even more configuration. We have not pointed it at the database yet, or set the ports, coin daemon details, etc… Let’s get into that.
Open up your ssh terminal again (putty) under your user.
cp /home/username/nomp/pool_configs/litecoin_example.json /home/username/nomp/pool_configs/litecoin.json
Open up WinSCP, navigate to
/home/username/nomp/pool_configs
You’ll see the new litecoin.json file you just copied over with that previous command. Right click on it and edit it.
-Change “enabled” to true. -“address” is that wallet address you saved earlier before, make sure you copy and paste that in there. -You’ll see “paymentProcessing” and “enabled” below that, change that to false. -Now you’ll see “ports” scroll down to where you see port “3032”, change it to “3333”. -Go down to where you see “daemons”. -Port will be 2300 if you copied my litecoin.conf settints from before. -“user” is your rpcuser from the litecoin.conf. -“password” is your rpcpassword from the litecoin.conf. -Scroll down to “p2p” and find the “enabled” below it and change it to false. -Scroll down to “mposMode”. -Change “enabled” to true. -Change “user” to the username you setup on the phpmyadmin step from before -Change “password” to the password you setup on the phpmyadmin step -Change “database” to the database you setup on the phpmyadmin step (we made it the same as username)
If any of the settings are wrong, your stratum will not work. Please double or triple check!
Make sure everything saved correctly, we will come back to NOMP later on. MPOS Initial Setup
Let’s setup MPOS (Mining Portal Open Source), which will be the frontend of your pool website.
Alright, let’s go this going. Login to ssh on your user if you are not already.
cd git clone https://github.com/MPOS/php-mpos.git mpos cd mpos
Setup permissions.
sudo chown –R www-data templates/compile templates/cache logs
Let’s copy over the configuration.
sudo cp include/config/global.inc.dist.php include/config/global.inc.php
Alright, now let’s setup the MPOS global configuration file. Open up WinSCP and navigate to
/home/username/mpos/include/config/
and right click on global.inc.php and edit it.
Alright, same as what I did with NOMP before. I will go through the steps of what to edit, and then ill post some screenshots of what I did afterwards.
-Scroll down to “SALT” and “SALTY”, see how it says make it something random? Literally mash on your keyboard and just get at least 20+ characters. This is what they use to scramble passwords. -Scroll down to “algorithm”, if you are using litecoin it should remain “scrypt” and you don’t have to change it. -Scroll down to “Database Configuration” -‘user’ will be the user you setup in phpmyadmin from before -‘pass’ is the password you generated on phpmyadmin -‘name’ is the name of the database you created with phpmyadmin before, we named it the same as the user if you followed the guide exactly. -Move down to “Local wallet RPC” -On ‘host’ change 19334 to 2300 -‘username’ to your rpcuser from the litecoin.conf -‘password’ to your rpcpassword from the litecoin.conf -Save it!
Now, for Litecoin the global config is all setup now. You can change the minimum and maximum auto-withdrawals, and everything else after you make sure the pool is operational.
Now we need to point the Apache Virtual Server towards the MPOS public directory.
Login to Webmin, https://yourserverip:10000/
-Go to Servers > Apache Webserver. -You should see the Virtual Server that says “Handles the name-based server on address *.”, click on that virtual server.
-Go to “Virtual Server Details” on the bottom -Find “Document Root” and change “/var/www/html” to “/home/username/mpos/public”,
-Click Save
Now we need to update the Apache configuration a bit.
-Click on “Global Configuration” on the top center left,
-Click on “Edit Config Files” -Scroll all the way to the bottom of the config file -Add this to the bottom, and update it according to your username obviously.
<Directory /home/username/mpos/public> Options Indexes FollowSymLinks AllowOverride None Require all granted
-Click Save -Click on “Apply Changes” in the type right of Webmin.
Now let’s see if the MPOS frontend is working, go to http://yourserverip
Its Possible that you wil get the following error (mpos Unable to load vendor libraries, please run php composer.phar install in root folder.) , if so use this commands:
sudo apt-get update sudo apt-get install php7.1-xml php composer.phar install
If you see the MPOS frontpage, then go ahead and skip to the “MPOS Frontend Initial” step.
If you get a blank page, don’t worry it may be a permissions issue. Login to root on ssh.
cd /home/username/mpos chown -R www-data templates/compile templates/cache logs
Now head back to http://yourserverip and see if MPOS shows up. MPOS Frontend
Before we get into the cronjobs, let’s go ahead and get familiar with MPOS.
Click on “Other” and then click “Sign up”
The first account on MPOS is the admin account and does not require email activation. Fill in the info and then click “Register” on the bottom.
he coin address is just your wallet, that you want your mined coins to go to. By default MPOS won’t let you register without one.
Also, if you are getting “token expired” messages don’t worry, it’s just MPOS being finicky. Try again.
You should get a “Please check your mailbox to activate” message, don’t worry you do not need to activate anything as the first account is the admin account.
Go ahead and login.
-Go to Admin Panel > System > Settings
-Click on “System” on that settings page:
-Find “Disable e-mail confirmations” and select yes. -Scroll to the bottom and click save.
Now you just set it so users can register without email confirmations, which is important if you don’t have a mail server setup. The other settings you can toy with later on after this guide is over, such as your pool name.
Last thing, go to Admin Panel > System > Monitoring This page is not important now, but it will be when we setup the cronjobs. Please keep it open in a tab on your browser for later. I will refer to it as the “Monitoring Page” in the cronjob section of this guide.
Do not worry if there is issues like “we can’t poke your Stratum server”, because the Stratum is not started yet. We will get into that here shortly. MPOS Cronjob Setup
MPOS work’s off of 3 different main cronjobs. Payout, statistics, and maintenance. There are others, but this is what we will be setting up. We will run them every minute, it is very important that you run these crons every minute otherwise MPOS likes to break.
Login to Webmin, http://yourserverip:10000/
Go to System > Scheduled Cronjobs
-Select “Create a new scheduled cronjob” on the bottom. -“Execute cron job as”, select your user. -“Active” will be yes. -Command will be “/home/username/mpos/cronjobs/run-statistics.sh” -Go down to “Minutes” and click on the “selected” and then highlight all the numbers. -Click “Create”
Now you will create 2 more cronjobs using the exact process we just did above, for “/home/username/mpos/cronjobs/run-maintenance.sh” and “/home/username/mpos/cronjobs/run-payout.sh”
I won’t repeat the process, it’s really straight forward and I am sure you can do it if you have gotten this far in the guide. Alright, remember that “Monitoring Page” I had you leave open? Go back to it, and hit refresh.
Your monitoring page should get new results pushed to it every minute, if not it’ll turn yellow and eventually red.
Congraulations, your cronjobs are setup.
Turning Stratum On
Remember NOMP? We are going to turn it on now.
Log back onto ssh (putty) as your user.
cd cd nomp
Before we set NOMP to stay on “forever” we are going to make sure it works first while we can still interact with it. Let’s start the stratum server in shell. node init.js
If you have no errors, then you are good your stratum is running. If you have issues, please go back to the NOMP setup part of the guide.
Now fire up your miner, I am not going to go into specifics about setting up cgminer or what have you. If you don’t know how to setup a miner, you probably should of researched that long before you attempted to setup your own pool.
Details for your miner:
stratum+tcp://yourserverip:3333
-u mposusername.1
-p x
Now type this to keep init.js running indefinitely (until you restart your server or nomp crashes). forever start init.js
Your Stratum is now running, and will stay running even if you close your ssh terminal.
Congratulations You have now your own Mining Pool Ready to Start
-
- installation of Redis requires TCL 8.5 or newer TCL Download Page