首页 > 代码库 > Bitcoind在CentOS6.4安装参考

Bitcoind在CentOS6.4安装参考

参考链接

https://bitcointalk.org/index.php?topic=35812.msg442140#msg442140

rpm方式

rpm -ivh http://linux.ringingliberty.com/bitcoin/el6/x86_64/bitcoin-release-1-6.noarch.rpm
yum install bitcoin-server

CentOS5参考

Ok let‘s get this tutorial section started off with one. Now mind you I didn‘t write this tutorial, it was writen by "Michael Erwin Steurer" and posted on the otherbitcoin forum. Problem is it was hard to find and it‘s in PDF format, don‘t like that myself ha ha

So I am going to post it here to get the tutorials section up and running. Plus, I also fixed a problem someone on the other forum was having with gthread not being installed and working, I will post that at the end of the tutorial.

Now I HAVE tested this myself just 10 minutes ago on a CentOS 5.5 system with the most recent of everything, including the most recent download ofbitcoin. So it works. Let‘s start:

We keep everything in our home directory under ~/Bitcoin/. We do not make any changes
to system parameters or system libraries and therefore no root privileges are required.

That above statement was from the original, root priviledges WILL be required if you have the problem with gthread, which most VPS machines should have. This is because you will have to install gthread using yum, so root is needed in this case or sudo power.

Libraries

Boost, Get the Library from here:
http://sourceforge.net/projects/boost/files/boost/1.46.1/boost_1_46_1.tar.gz

put it into the directory ~/Bitcoin/Libraries/ and execute the following commands (write the parameters for the bjam command in one line).

There was an error in the prefix line below, I removed it, the author had an extra Bitcoin/ in there.

# cd Libararies
# tar -xzvf boost_1_46_1.tar.gz
# cd boost_1_46_1
# ./bootstrap.sh
# ./bjam --prefix=../../Deps link=static runtime-link=static install
OpenSSL, Get the Library from here:
http://www.openssl.org/source/openssl-1.0.0d.tar.gz

And put it into the directory ~/Bitcoin/Libraries/, extract it and determine the system architecture.

# tar -xzvf openssl-1.0.0d.tar.gz
# cd openssl-1.0.0d
# uname -a
If the ouput of the last command contains

x86_64 x86_64 x86_64 GNU/Linux
you have a 64-bit computer architecture and if it contains

i686 i686 i386 GNU/Linux
you have a 32-bit computer architecture.

Execute one of the following ./Con gure commands according to the architecture

64-bit architecture

# ./Configure --prefix=~/Bitcoin/Deps --openssldir=~/Bitcoin/Deps/openssl linux-x86_64
32-bit architecture

# ./Configure --prefix=~/Bitcoin/Deps --openssldir=~/Bitcoin/Deps/openssl linux-generic32
Get a list with all supported architectures

# ./Configure --prefix=~/Bitcoin/Deps --openssldir=~/Bitcoin/Deps/openssl
Finally, compile and install.

make && make install
Berkeley DB, Get the Library from here:
http://freshmeat.net/projects/berkeleydb

And put it into the directory ~/Bitcoin/Libraries/ and compile it

# tar -xzvf db-5.1.19.tar.gz
# cd db-5.1.19
# cd build_unix
# ../dist/configure --prefix=~/Bitcoin/Deps/ --enable-cxx
# make && make install
Bitcoin

Get the BitCoin sources from the webpage or check it out from the Git repository and put
it into the directory ~/Bitcoin/Trunk/

# git clone https://github.com/bitcoin/bitcoin.git Trunk
That was the GIT command, now you can download also from here:

BitCoin homepage:
http://www.bitcoin.org/

BitCoin GIT:
https://github.com/bitcoin/bitcoin

Or SourceForge page, you want to download the latest version and the src version to compile your self:
http://sourceforge.net/projects/bitcoin/files/Bitcoin/

I personally got mine from the SF page

To download and compile from SF, use wget, issue these commands:

# cd ~/Bitcoin/Trunk
# wget sf_link
# tar -xf bitcoin*
# cd bitcoin-0.3.23/src


Replace sf_link with your download link and 0.3.23 with the version you downloaded.

Create a new fille ~/Bitcoin/Trunk/makefi le.centos and add the lines as follows.

#begin


# Copyright (c) 2009-2010 Satoshi Nakamoto
# Distributed under the MIT/X11 software license, see the accompanying
# file license.txt or http://www.opensource.org/licenses/mit-license.php.


CXX=g++


DEPSDIR=/root/Bitcoin/Deps


INCLUDEPATHS= -I"$(DEPSDIR)/include"
LIBPATHS= -L"$(DEPSDIR)/lib"


WXINCLUDEPATHS=$(shell wx-config --cxxflags)
WXLIBS=$(shell wx-config --libs)


USE_UPNP=


DEFS= -DNOPCH -DFOURWAYSSE2 -DUSE_SSL


LIBS= -dead_strip \
-Wl,-Bstatic \
$(DEPSDIR)/lib/libdb_cxx-5.1.a \
-mtl $(DEPSDIR)/lib/libboost_system.a \
-mtl $(DEPSDIR)/lib/libboost_thread.a \
-mtl $(DEPSDIR)/lib/libboost_filesystem.a \
-mtl $(DEPSDIR)/lib/libboost_program_options.a \
$(DEPSDIR)/lib/libdb_cxx.a \
$(DEPSDIR)/lib/libssl.a \
$(DEPSDIR)/lib/libcrypto.a \
-l ssl \
-l crypto \
-Wl,-Bdynamic \
-l gthread-2.0 \
-l z \
-l dl


ifdef USE_UPNP
LIBS += -l miniupnpc
DEFS += -DUSE_UPNP=$(USE_UPNP)
endif


DEBUGFLAGS=-g -D__WXDEBUG__
CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS)
HEADERS=headers.h strlcpy.h serialize.h uint256.h \
util.h key.h bignum.h base58.h script.h \
db.h net.h irc.h main.h rpc.h uibase.h \
ui.h noui.h init.h


OBJS= obj/util.o \
obj/script.o \
obj/db.o \
obj/net.o \
obj/irc.o \
obj/main.o \
obj/rpc.o \
obj/init.o \
cryptopp/obj/sha.o \
cryptopp/obj/cpu.o


all: bitcoind




obj/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CXXFLAGS) $(WXINCLUDEPATHS) -DGUI -o $@ $<


cryptopp/obj/%.o: cryptopp/%.cpp
$(CXX) -c $(CXXFLAGS) -O3 -o $@ $<


bitcoin: $(OBJS) obj/ui.o obj/uibase.o
$(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ $(WXLIBS) $(LIBS)


obj/nogui/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CXXFLAGS) -o $@ $<


bitcoind: $(OBJS:eek:bj/%=obj/nogui/%)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)


clean:
-rm -f obj/*.o
-rm -f obj/nogui/*.o
-rm -f cryptopp/obj/*.o
-rm -f headers.h.gch
-rm -f bitcoin
-rm -f bitcoind


#end



The spaces that you see are not spaces, they are TABS, one single tab to be exact since make is picky about this make sure you use tabs not spaces.

Change the Value DEPSDIR according to your Deps/ directory.

Finally, compile the sources in the ~/Bitcoin/Trunk directory. This also depends on where you extracted the files from the source file to and from, you want to be in the SRC directory if you downloaded from SF instead of GIT.

make -f makefile.centos bitcoind
Now for those of you with this error when you make:

cannot find -lgthread-2.0


You need to install glib2-devel, that is the LIB that contains gthread for CentOS, you can do this issueing this command as root or sudo:

yum install glib2-devel.i386


For that you might need the extras repositories from CentOS, you can find instructions on how to install the extra repos here:
http://wiki.centos.org/AdditionalResources/Repositories/RPMForge