HOW TO BUILD YOUR OWN CRYPTOCURRENCY MINING POOL


This install guide will assist you with installing Pushpool 5.1 .

Pushpool  is just a back-end if you would like to operate a pool like deepbit.net you need frontend software which would require a Virtual Hosting Service(VPS) or a Dedicated Server. A front-end does all the pay-outs, user/worker management, and stats if you don't feel like developing your own software you can build off of already made front-ends such as
Mining Farm which can get you up and running with in a couple of minutes provided that you have full root access to your server with Apache2 and PHP installed along with basic knowledge of setup Cronjobs or Crontabs.

First off your going to want to download the latest pushpool version (offical updated download page: 
http://forum.bitcoin.org/index.php?topic=8707.0;topicseen)
http://yyz.us/bitcoin/pushpool-0.5.1.tar.gz
and click "Downloads" then make sure you get the one that says Download .tar.gz

Before we start we are going to do a update for the system packages right now
Code:
sudo apt-get install update;
sudo apt-get install build-essential;

Once you extract the downloaded pushpool.tar.gz file on to your server your going to first want to run ./autogen.sh

Code:
./autogen.sh

On my fresh Ububntu server install right off the bat I had an Aclocal type error in which my case I had to install Automake to get past it
Code:
sudo apt-get install automake

Okay if you got the aclocal/automake error you should now run ./autogen.sh once more and it should spit out some files such as ./configure file
Next were going to attempt to run the configure file
Code:
./configure --prefix=/home/pushpool_install_directory

I was then presented with another problem that looks like this
Quote
configure:2039: checking for a BSD-compatible install
configure:2107: result: /usr/bin/install -c
configure:2118: checking whether build environment is sane
configure:2168: result: yes
configure:2309: checking for a thread-safe mkdir -p
configure:2348: result: /bin/mkdir -p
configure:2361: checking for gawk
configure:2377: found /usr/bin/gawk
configure:2388: result: gawk
configure:2399: checking whether make sets $(MAKE)
configure:2421: result: yes
configure:2505: checking whether to enable maintainer-specific portions of Makefiles
configure:2514: result: no
configure:2532: checking build system type
configure:2546: result: x86_64-unknown-linux-gnu
configure:2566: checking host system type
configure:2579: result: x86_64-unknown-linux-gnu
configure:2648: checking for gcc
configure:2678: result: no
configure:2741: checking for cc
configure:2788: result: no
configure:2844: checking for cl.exe
configure:2874: result: no
configure:2898: error: in `/home/pushpoolInstaller':
configure:2900: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Which meant no compiler was installed so i went with this command to get a compatible compiler installed
Code:
sudo apt-get install gcc

Now lets run configure again
Code:
./configure

My system stopped the configure after finding out there is no libevent which the error looked like this
Quote
configure: error: Missing required libevent

If your receiving the same error do the following

Libevent install instructions
Get libevent source code
Code:

Next extract the source code where you would like, for simplicity I extracted inside of the pushpool source code files
Code:
tar xzvf libevent-2.0.12-stable.tar.gz

now we change into the libevent directory so we can install libevent
Code:
cd libevent-2.0.12-table.tar.gz

now we are going to ./configure libevent
Code:
./configure

if you got no errors do the following
Code:
make;
make install;

Those command should output something like this
Quote
le'
make[3]: Entering directory `/home/pushpoolInstaller/libevent-2.0.12-stable/sample'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/pushpoolInstaller/libevent-2.0.12-stable/sample'
make[2]: Leaving directory `/home/pushpoolInstaller/libevent-2.0.12-stable/sample'
Making install in test
make[2]: Entering directory `/home/pushpoolInstaller/libevent-2.0.12-stable/test'
make  install-am
make[3]: Entering directory `/home/pushpoolInstaller/libevent-2.0.12-stable/test'
make[4]: Entering directory `/home/pushpoolInstaller/libevent-2.0.12-stable/test'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory `/home/pushpoolInstaller/libevent-2.0.12-stable/test'
make[3]: Leaving directory `/home/pushpoolInstaller/libevent-2.0.12-stable/test'
make[2]: Leaving directory `/home/pushpoolInstaller/libevent-2.0.12-stable/test'
make[1]: Leaving directory `/home/pushpoolInstaller/libevent-2.0.12-stable'

now we have libevent installed(if you received no errors that is)!

Now lets change back into the pushpoold install directory were we first started off in this tutorials case
we are going to do cd ..
Code:
cd ..


Now we should be in the pushpool installer, lets try to configure again!
Code:
./configure --prefix=/home/pushpool_install_directory

So it looks like in a fresh Ubuntu server we need to install Zlib which should be an easy package get so lets retrieve the latest source code by getting doing this
Code:

Then were going to extract the file
Code:


Now were going to cd into zlib
Code:

Now lets compile this baby!
Code:
./configure;
make;
make install;

 You should have gotton no errors lets continue on to our pushpool installation

Move to your pushpool install file directory in this tutorials case it is just simply
Code:
cd ..


Lets try another configure on pushpool again
Code:
./configure --prefix=/home/pushpool_install_directory

I'm now getting a Jansson error when configuring that looks like this
Quote
checking for json_loads in -ljansson... no
configure: error: Missing required jansson library

So now lets get the jansson source code (Offical website: 
http://www.digip.org/jansson/);

Code:

Do extraction like usual
Code:
tar xvf jansson-2.1.tar.gz

Move into directory like normal
Code:
cd jansson-2.1.tar.gz

Now lets do some compiling!
Code:
./configure
this should output a bunch of lines and should finish with the following messages
Quote
configure: creating ./config.status
config.status: creating jansson.pc
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating src/jansson_config.h
config.status: creating test/Makefile
config.status: creating test/bin/Makefile
config.status: creating test/suites/Makefile
config.status: creating test/suites/api/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

If so we are on the right track and almost finished with installing *Wipes sweat*

Now lets do the installing part for jansson
Code:
make;
make install;

Which should out put something like this
Quote
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/pushpoolInstaller/jansson-2.1/test'
make[2]: Leaving directory `/home/pushpoolInstaller/jansson-2.1/test'
make[1]: Leaving directory `/home/pushpoolInstaller/jansson-2.1/test'
make[1]: Entering directory `/home/pushpoolInstaller/jansson-2.1'
make[2]: Entering directory `/home/pushpoolInstaller/jansson-2.1'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/lib/pkgconfig" || /bin/mkdir -p "/usr/local/lib/pkgconfig"
 /usr/bin/install -c -m 644 jansson.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory `/home/pushpoolInstaller/jansson-2.1'
make[1]: Leaving directory `/home/pushpoolInstaller/jansson-2.1'

If yours looks similar we are straight planking at this point... lol jk nobody planks any more that was so 2010, moving on....


Anyways we now have Jansson installed so lets move back to our pushpool installing directory in our case we just do a simple
Code:
cd ..

Now lets see if pushpool has anything to say this time
Code:
./configure --prefix=/home/pushpool_install_directory

Yep it looks like for me OpenSSL wasn't installed
lets install it by running
Code:
sudo apt-get install libssl-dev


Now we got OpenSSL installed for sure we should try doing ./configure again
Code:
./configure --prefix=/home/pushpool_install_directory

So pushpool is still pissed and it needs the support of libmemcached library (offical website: 
https://launchpad.net/libmemcached/+download)
so lets install it

first we need to install memcached which is what libmemcached relies on
so lets do a quick
Code:
sudo apt-get install memcached;
and we need libtool aparently
Code:
sudo apt-get install libtool;

next we get the source
Code:

extract the source into folders
Code:
tar xvf libmemcached-0.50.tar.gz

move into the new directory
Code:
cd libmemcached-0.50.tar.gz

configure
Code:
./configure;
Which should look like this if done correctly
Quote
Configuration summary for libmemcached version 0.50

   * Installation prefix:       /usr/local
   * System type:               unknown-linux-gnu
   * Host CPU:                  x86_64
   * C Compiler:                gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
   * Assertions enabled:        yes
   * Debug enabled:             no
   * Warnings as failure:       no

---

Now make install
Code:
make;
make install;

which should look like this at the end of the output if done correctly
Quote
/usr/bin/install -c -m 644 support/libmemcached.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory `/home/pushpoolInstaller/libmemcached-0.50'
make[1]: Leaving directory `/home/pushpoolInstaller/libmemcached-0.50'

So now lets go back to pushpool and see what it wants to b*tch about this time... 
Code:
cd ..


Oh great... another error

so it looks like i don't have any database development files installed becuase i got the end output that looks like this
Quote
checking for SQLite3 library >= 3.0.0... not found
checking for mysql_config... no
checking for mysql_config5... no
checking for pg_config... no

so I'm going to pick mysql databse as our choice for install you can install any database you want here, it just must be compatible with pushpoold and you must install the required dev files for that database system such as SQLite or postql but i picked MySql becuase I like it.
Code:
sudo apt-get install libmysql++-dev





And back to pushpool installer... so now we should definably be able to run ./configure
Code:
./configure

it should out put something like this
Quote
configure: creating ./config.status
config.status: creating Makefile
config.status: creating autotools-config.h
config.status: executing depfiles commands

Which means we can go ahead and do a 
Code:
make;
make install;

which the last lines of the output will look like this
Quote
test -z "/usr/local/sbin" || /bin/mkdir -p "/usr/local/sbin"
  /usr/bin/install -c pushpoold '/usr/local/sbin'
test -z "/usr/local/sbin" || /bin/mkdir -p "/usr/local/sbin"
 /usr/bin/install -c blkmond '/usr/local/sbin'
make[1]: Nothing to be done for `install-data-am'.
make[1]: Leaving directory `/home/pushpool-0.5.1'

This means that it worked!!! but theres still more to be done..... OH Linux! I <3 U!


Okay first thing we want to do is move into the directory that we set the --prefix= variable to which in our case was "/home/pushpoolInstaller/"
Code:
cd /home/pushpoolInstaller

So there should be a pushpool file that we could run like this
Code:
./pushpool -E -F

Which should have returned the following error message..
Quote
[2011-07-06 14:08:36.131550] config file(server.json): No such file or directory

So lets create that server.json file which by the way if your having issues with the server.json file configuration or setup please go to the following thread for json support: 
http://forum.bitcoin.org/index.php?topic=26504.0

server.json configuration file
Code:
{
      # network ports
      "listen" : [
            # binary protocol (default), port 8342
            { "port" : 8342 },

            # HTTP JSON-RPC protocol, port 8341
            { "port" : 8341, "protocol" : "http-json" },

            # HTTP JSON-RPC protocol, port 8344,
            # with trusted proxy appserver.example.com forwarding
            # requests to us
            { "port" : 8332, "protocol" : "http-json",
              "proxy" : "127.0.0.1" },

            # binary protocol, localhost-only port 8338
            { "host" : "127.0.0.1", "port" : 8338, "protocol" : "binary" }
      ],

      # database settings
      "database" : {
            "engine" : "mysql",
            "host" : "localhost",
            "port" : 3306,
            "name" : "mysql_database_name",
            "username" : "mysql_username",
            "password" : "mysql_password",
            "sharelog" : true,
            "stmt.pwdb":"SELECT `password` FROM `pool_worker` WHERE `username` = ?",
            "stmt.sharelog":"INSERT INTO shares (rem_host, username, our_result, upstream_result, reason, solution) VALUES (?, ?, ?, ?, ?, ?)"

      },

      # cache settings
      "memcached" : {
            "servers" : [
                  { "host" : "127.0.0.1", "port" : 11211 }
            ]
      },

      "pid" : "/tmp/pushpoold.pid",

      # overrides local hostname detection
      "forcehost" : "localhost.localdomain",

      "log.requests" : "/tmp/request.log",
      "log.shares" : "/tmp/shares.log",

      # the server assumes longpolling (w/ SIGUSR1 called for each blk)
      "longpoll.disable" : false,

      # length of time to cache username/password credentials, in seconds
      "auth.cred_cache.expire" : 75,

      # RPC settings | Notice how this ISN'T port number 8332 this is becuase the same port number should not becuase inconjunction with the JSON RPC port other wise you'll get 500 errors
      "rpc.url" : "http://127.0.0.1:8333/",
      "rpc.user" : "bitcoinRPC_wallet_username",
      "rpc.pass" : "bitcoinRPC_wallet_password",

      # rewrite returned 'target' to difficulty-1?
      "rpc.target.rewrite" : true
}

Okay so now that we saved our server.json file in the same folder as puspoold we can now run pushpoold again in Debug mode and see what it says this time
Code:
./pushpoold -E -F

It should output somthing like this
Quote
[2011-07-06 14:35:9.866836] Listening on host :: port 8352
[2011-07-06 14:35:9.867064] Listening on host :: port 8351
[2011-07-06 14:35:9.867160] Listening on host :: port 8332
[2011-07-06 14:35:9.867242] Listening on host 127.0.0.1 port 8338
[2011-07-06 14:35:9.869570] initialized

If it ends with initialized 99% of the time your golden and that its is fully operational in the sense that "It connected to bitcoind, It connected to a database set in the json file, and that its got all the permissions it needs"
So go ahead and point your miner to the port number you specified in the server.json file where the line that says this
Code:
            # HTTP JSON-RPC protocol, port 8344,
            # with trusted proxy appserver.example.com forwarding
            # requests to us
            { "port" : 8332, "protocol" : "http-json",
              "proxy" : "127.0.0.1" },

Now all you need is a front-end which will manage all your miners stats, work load, efficiency, overview look of the entire pool, how many and which blocks were found and confirmed as well as invalid blocks, if you said yes to one or all of those, you can download commerical software that usually goes for $100-$300 a license OR you can get for free working and safe condition over at the official Mining Farm thread
http://forum.bitcoin.org/index.php?topic=10617.0