Want live help from a dedicated Tech Agent?

How to install Bitcoin in your server

Amal 3 years ago - Created

If you are using AWS you have to enable following port.
Port: 18523

1. Login to the Droplet

We will connect to the server with the SSH key we added to the server in Step 1.

Copy your IP address we created in Step 1. You’ll find your IP address here:

Enter the command below in your Terminal, substituting the your_server_ip with the IP address of your Droplet for and {path_to_serverkey} with the file path of the private SSH key we created earlier:

ssh [email protected]_server_ip -i {path_to_serverkey}

Hit Enter. You will be prompted to enter the passphrase we created while creating this private key. Enter the password and press Enter again.

If you are on Mac, you might be prompted to type your keychain password.

2. Install Apache

Our next step is to install Apache. Type the following commands in the terminal:

sudo apt-get update
sudo apt-get install apache2
You will be prompted with a (Y/n). Type y and press Enter.

You have now installed Apache web server successfully.

3. Install PHP

PHP is the component of our setup that will process code to display dynamic content. It can run scripts, connect to our MySQL databases to get information and hand the processed content over to our web server to display.

Step 1: Install PHP to server Type the following commands into the terminal:

sudo apt-get install php7.0 libapache2-mod-php php-mcrypt php-mysql php-gd php-bcmath
You will be prompted with a (Y/n). Type y and press Enter.

This should install PHP without any problems.

Change the location of index.php

To do this, type this command to open the dir.conf file in a text editor with root privileges:

sudo nano /etc/apache2/mods-enabled/dir.conf

Inside of the file will look like this:

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

We want to move the index.php file above to the first position after the DirectoryIndex, like this:

DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

When you are finished, Press Control + O to save.

And press Enter.

Then press Control + X to exit.

You have now installed PHP successfully.

4. Install CLI and CURL

To do this, type the following command into your Terminal:

sudo apt-get install php-cli php-curl curl
You will be prompted with a (Y/n). Type y and press Enter.

You have now installed CLI and CURL successfully.

5. Install Bitcoin blockchain

Run the following commands one by one to install Bitcoin Daemon.

sudo apt-add-repository ppa:bitcoin/bitcoin
You will be prompted to type 'ENTER' to continue.
sudo apt-get update
sudo apt-get install bitcoind
You will be prompted with a (y/n). Enter 'y' to continue.

6. Configure the bitcoin installation

1. Create a directory name .bitcoin in the root directory with the following command:

mkdir .bitcoin

2. Create a conf file named bitcoin inside the above directory with the below command:

cd .bitcoin
sudo nano bitcoin.conf

A new file will be created and it will look like this:

3. Enter the following lines into the new files to configure this blockchain to work with our exchange script, substituting ip_address_of_bitexchange with the IP address of the server we have hosted the crypto exchange script and 32_character_alphanumeric_string with a 32 character alphanumeric password. You can use a random password generator site to generate a password if you like.

walletnotify=/var/www/html/cron/receive.sh %s

Now, save the file by pressing Control + O.

Then press Enter.

Finally, press Control + O to exit.

4. Open the rpc port we have given above:

ufw allow 22
ufw allow 80
ufw allow 443
ufw allow 18523
ufw enable

5. Now, connect to your server using Filezilla using the IP address of the bitcoin droplet. Drag and drop the cron.zip you have downloaded to the /var/www/html/ folder in your bitcoin droplet using Filezilla:

6. Now go to your Terminal and install Unzip by running the following command:

sudo apt-get install unzip

7. Navigate to the html folder:

cd /var/www/html

8. And type the unzip command in your Terminal and press Enter.

unzip cron.zip

9. Navigate to the cfg file inside cron folder.

cd /var/www/html/cron/

10. Open the cfg.php file inside this location with the following command:

sudo nano cfg.php

Update the dbname and dbpass values like we did in Step 6. Save and close the file.

7. Configure admin panel to receive updates

1. Login to your admin panel by visiting admin.yourexchangedomain.com. If you haven't changed the password, the default credential is 

Username: admin

Password: DminaDminaDmina

2. Go to Currencies>Cryptocurrency Wallets.

3. We are configuring bitcoin, hence go BTC column and press Edit icon.

4. Update the connection to Daemon fields with the values you have given in your bitcoin.conf file and press Save.

8. Configure Cron

Configure Cron to start the bitcoin daemon when the server restarts using the following commands:

sudo crontab -e

Go to the end of the file and add the following line:

*/1 * * * * /var/www/html/cron/process_bitcoin.sh

@reboot bitcoind -daemon

Save by pressing Control + O.

Press Enter.

Press Control + X to exit.

9. Run Bitcoin daemon

Next, run the bitcoin daemon using the command:

    bitcoind -daemon  

check the blockcain information after your server gets started using the following command line

    bitcoin-cli getblockchaininfo

You have now installed bitcoin blockchain on your server.

Was this article helpful?

11 out of 11 found this helpful

Articles in this section