1 How to run your own Electrum server
2 ===================================
7 This document is an easy to follow guide to installing and running your own
8 Electrum server on Linux. It is structured as a series of steps you need to
9 follow, ordered in the most logical way. The next two sections describe some
10 conventions we use in this document and hardware, software and expertise
13 The most up-to date version of this document is available at:
15 https://github.com/spesmilo/electrum-server/blob/master/HOWTO.md
20 In this document, lines starting with a hash sign (#) or a dollar sign ($)
21 contain commands. Commands starting with a hash should be run as root,
22 commands starting with a dollar should be run as a normal user (in this
23 document, we assume that user is called 'bitcoin'). We also assume the
24 bitcoin user has sudo rights, so we use '$ sudo command' when we need to.
26 Strings that are surrounded by "lower than" and "greater than" ( < and > )
27 should be replaced by the user with something appropriate. For example,
28 <password> should be replaced by a user chosen password. Do not confuse this
29 notation with shell redirection ('command < file' or 'command > file')!
31 Lines that lack hash or dollar signs are pastes from config files. They
32 should be copied verbatim or adapted, without the indentation tab.
37 **Expertise.** You should be familiar with Linux command line and
38 standard Linux commands. You should have basic understanding of git,
39 Python packages. You should have knowledge about how to install and
40 configure software on your Linux distribution. You should be able to
41 add commands to your distribution's startup scripts. If one of the
42 commands included in this document is not available or does not
43 perform the operation described here, you are expected to fix the
44 issue so you can continue following this howto.
46 **Software.** A recent Linux distribution with the following software
47 installed: `python`, `easy_install`, `git`, standard C/C++
48 build chain. You will need root access in order to install other software or
51 **Hardware.** The lightest setup is a pruning server with diskspace
52 requirements well under 1 GB growing very moderately and less taxing
53 on I/O and CPU once it's up and running. If you have more ressources to spare
54 you can run the server with a higher limit of historic transactions per address.
55 CPU speed is also important, mostly for the initial block chain import, but
56 also if you plan to run a public Electrum server, which could serve tens
57 of concurrent requests.
62 ### Step 1. Create a user for running bitcoind and Electrum server
64 This step is optional, but for better security and resource separation I
65 suggest you create a separate user just for running `bitcoind` and Electrum.
66 We will also use the `~/bin` directory to keep locally installed files
67 (others might want to use `/usr/local/bin` instead). We will download source
68 code files to the `~/src` directory.
70 # sudo adduser bitcoin
75 If you don't see `/home/bitcoin/bin` in the output, you should add this line
76 to your `.bashrc`, `.profile` or `.bash_profile`, then logout and relogin:
78 PATH="$HOME/bin:$PATH"
80 ### Step 2. Download and install Electrum
82 We will download the latest git snapshot for Electrum and 'install' it in
85 $ mkdir -p ~/src/electrum
87 $ git clone https://github.com/spesmilo/electrum-server.git server
88 $ chmod +x ~/src/electrum/server/server.py
89 $ ln -s ~/src/electrum/server/server.py ~/bin/electrum
91 ### Step 2. Download Bitcoind from git & patch it
93 In order for the latest versions of Electrum to work properly we will need to use the latest
94 build from Git and also patch it with an electrum specific patch.
95 Please make sure you run a version of bitcoind from git from at least December 2012 or newer:
97 $ cd src && git clone git://github.com/bitcoin/bitcoin.git
99 $ patch -p1 < ~/src/electrum/server/patch/patch
100 $ cd src && make -f makefile.unix
102 ### Step 3. Configure and start bitcoind
104 In order to allow Electrum to "talk" to `bitcoind`, we need to set up a RPC
105 username and password for `bitcoind`. We will then start `bitcoind` and
106 wait for it to complete downloading the blockchain.
109 $ $EDITOR ~/.bitcoin/bitcoin.conf
111 Write this in `bitcoin.conf`:
113 rpcuser=<rpc-username>
114 rpcpassword=<rpc-password>
121 Allow some time to pass, so `bitcoind` connects to the network and starts
122 downloading blocks. You can check its progress by running:
126 You should also set up your system to automatically start bitcoind at boot
127 time, running as the 'bitcoin' user. Check your system documentation to
128 find out the best way to do this.
130 ### Step 5. Install Electrum dependencies and leveldb
132 Electrum server depends on various standard Python libraries. These will be
133 already installed on your distribution, or can be installed with your
134 package manager. Electrum also depends on two Python libraries which we will
135 need to install "by hand": `JSONRPClib`.
137 $ sudo easy_install jsonrpclib
140 Then carry out the steps in README.leveldb to get your system ready for
143 ### Step 6. Select your limit
145 Electrum server uses leveldb to store transactions. You can choose
146 how many spent transactions per address you want to store on the server.
147 The default is 100, but there are also servers with 1000 or even 10000.
148 Very few addresses have more than 10000 transactions. A limit this high
149 can be considered to be equivalent to a "full" server. Full servers previously
150 used abe to store the blockchain. The use of abe for electrum servers is now
153 The pruning server uses leveldb and keeps a smaller and
154 faster database by pruning spent transactions. It's a lot quicker to get up
155 and running and requires less maintenance and diskspace than abe.
157 The section in the configuration file looks like this:
160 path = /path/to/your/database
161 # for each address, history will be pruned if it is longer than this limit
164 ### Step 7. Import blockchain into the database or download it
166 As of April 2013 it takes between 12-24 to import 230k of blocks, depending
167 on CPU speed, I/O speed and selected pruning limit.
169 It's considerably faster to index in memory. You can use /dev/shm or indexing in RAM
170 or create a tmpfs which will also use swap if you run out of memory:
172 $ sudo mount -t tmpfs -o rw,nodev,nosuid,noatime,size=6000M,mode=0777 none /tmpfs
174 At limit 10000 the database comes to 3,5 GB with 230k blocks.
176 Alternatively you can fetch a pre-processed leveldb from the net
178 You can fetch recent copies of electrum leveldb databases and further instructions
179 from the Electrum full archival server foundry at:
180 http://electrum-foundry.no-ip.org/
182 ### Step 8. Configure Electrum server
184 Electrum reads a config file (/etc/electrum.conf) when starting up. This
185 file includes the database setup, bitcoind RPC setup, and a few other
188 $ sudo cp ~/src/electrum/server/electrum.conf.sample /etc/electrum.conf
189 $ sudo $EDITOR /etc/electrum.conf
191 Go through the sample config options and set them to your liking.
192 If you intend to run the server publicly have a look at README-IRC.md
194 If you're looking to run SSL / HTTPS you need to generate a self-signed certificate
195 using openssl. Otherwise you can just comment out the SSL / HTTPS ports and run
198 ### Step 9. (Finally!) Run Electrum server
200 The magic moment has come: you can now start your Electrum server:
204 You should see this on the screen:
206 starting Electrum server
209 If you want to stop Electrum server, open another shell and run:
211 $ electrum-server stop
213 You should also take a look at the 'start' and 'stop' scripts in
214 `~/src/electrum/server`. You can use them as a starting point to create a
215 init script for your system.
217 ### Step 10. Test the Electrum server
219 We will assume you have a working Electrum client, a wallet and some
220 transactions history. You should start the client and click on the green
221 checkmark (last button on the right of the status bar) to open the Server
222 selection window. If your server is public, you should see it in the list
223 and you can select it. If you server is private, you need to enter its IP
224 or hostname and the port. Press Ok, the client will disconnect from the
225 current server and connect to your new Electrum server. You should see your
226 addresses and transactions history. You can see the number of blocks and
227 response time in the Server selection window. You should send/receive some
228 bitcoins to confirm that everything is working properly.
230 ### Step 11. Join us on IRC, subscribe to the server thread
232 Say hi to the dev crew, other server operators and fans on
233 irc.freenode.net #electrum and we'll try to congratulate you
234 on supporting the community by running an Electrum node
236 If you're operating a public Electrum server please subscribe
237 to or regulary check the following thread:
238 https://bitcointalk.org/index.php?topic=85475.0
239 It'll contain announcements about important updates to Electrum
240 server required for a smooth user experience.