Installing Bitcart on Digitalocean

This is a tutorial to install Bitcart on cloud. Digitalocean here is used as example, you can select any cloud provider you like, if you need something cheeper, you can use any cloud provider.

Prerequisites

To start this tutorial, you will need a created digitalocean account with billing set up. You can do the same in any cloud provider.

Creating a droplet

In Digitalocean terms, droplet is your cloud server. Go to droplets section in menu, you will see something like this:

../../_images/1.png

Click on create droplet button, you will see settings. For this tutorial, I have selected the following settings:

../../_images/2.png ../../_images/3.png

You can select any plan you want, but using ubuntu 18.04 x64 is a recommended os. Before creating server, let’s set up authentification. Recommended method is ssh public key authentification. Another way is password authentification, which is a way less secure.

Optional: Adding ssh public key

Generate an ssh public key, on linux do it using:

ssh-keygen

Passphrase is not required.

The output would be like the following:

../../_images/4.png

If you need more information, refer to this guide by Digitalocean: https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-openssh/ https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/create-with-putty/

After generating, press New SSH Key button, and paste your public key. If you user is alex, then your public key would be in /home/alex/.ssh/id_rsa.pub

Copy its contents and paste it in this window, and give it the name you like:

../../_images/5.png

Then, select this new created ssh key for use with this droplet:

../../_images/6.png

Another authentification way: password

If you will not use public key authentification, then digitalocean will send you your password via email

Creating droplet: finalizing

Then, press on create droplet button, and wait till it is created:

../../_images/7.png

After creating, you’ll see something like that:

../../_images/8.png

Press on your droplet, and copy(and save somewhere) you new droplet’s ip address.

../../_images/9.png

For this droplet it is 142.93.110.169.

Connecting to new server

We can use any utility available, for example ssh on linux, but to make this guide similar to all platforms, let’s use putty. Refer to https://www.putty.org/ to download it on windows.

To install it on linux, run:

sudo apt install putty putty-tools

Then, launch putty, and set it up similar to this screen:

../../_images/10.png

In Host Name(or IP address) section paste ip address of your new server, name your session the way you want.

../../_images/14.png

To make openssh keys work with putty(if you’re on linux or mac os, not used putty to generate those before), open terminal in your ssh keys directory, it will be /home/alex/.ssh for user alex, and run:

puttygen id_rsa -o id_rsa.pub

Like so:

../../_images/14.png

Then, in auth section, select path to your generated .ppk file:

../../_images/11.png

Then, save your session:

../../_images/12.png

Press on Open button, it will connect to your server. When connecting to it first time, you might see this window:

../../_images/13.png

Press on accept button to start connection.

After that, enter root in login as: prompt.

You will see something similar to this:

../../_images/15.png

Congratulations, you has just finished buying your droplet and connecting to your new server!

Bitcart setup

Now, run the following script:

git clone https://github.com/MrNaif2018/bitcart-docker
cd bitcart-docker

Optionally, you can set up a domain. For that, visit setting up a domain in freenom section of this tutorial to know how to make it work. In general, you will need to set up an A record pointing to ip address of your server. BITCART_HOST(optional, if not specified you can access your server from ip address) is your host(without any http:// or https://, just domain) BITCART_LETSENCRYPT_EMAIL(optional) is email for you to be notified on some actions about your certificate.

export BITCART_HOST=mydomain.com
export BITCART_LETSENCRYPT_EMAIL=[email protected]
./setup.sh

Screenshots of what you will probably see:

../../_images/16.png

Now, let’s run our bitcart instance! Let’s use screen to make it running even when we log out. In near future we’ll add scripts to make it run automatically without any setup via systemd.

Run:

sudo screen

If it says like unrecognized command, then type:

sudo apt install screen

You will see something like that:

../../_images/18.png

Press enter to enter your ‘screen’. Now, it’s time to run bitcart!

Use ./start.sh to start bitcart.

Wait till it gets ready, it will download other docker images if running for the first time or if update is needed.

../../_images/19.png ../../_images/20.png

After running it, you can open your-ip-address-here or yourdomain.tld in browser and see bitcart instance.

../../_images/26.png

But, you may have a question, how do you login. You can register, but you won’t have access to server admin pages.

You can run ./create_admin to create a superuser(admin of the server), which will provide you full control over server from gui. Important, you must start bitcart containers first using ./start command if not yet. It will prompt you for email, name and password.

../../_images/39.jpg

After that, feel free to login and use bitcart!

../../_images/29.png ../../_images/30.png

👉 Tip! If you want full access to your server from gui, even if it wasn’t yet fully implemented, you can always access django admin at /admin url.

../../_images/tip1.png

Optional: Setting up a domain

👉 UPDATE: setting up a domain is super easy now, text below is left as reference if needed. To set up a domain you should just set BITCART_HOST environment variable, this is shown in installation part. Nginx configuration isn’t needed, but you can look how to set up A record below.

If you need an https certificate and a domain, here is a guide how to do it. First of all, you’ll need a domain. If you don’t have any yet and want to try it out, we can use freenom to get free .tk(or .ga, .ml and other) domain.

Registering a domain at freenom

First, register and login at https://freenom.com.

../../_images/31.png

Click on Register a New domain button, search a domain, select it and checkout, checkout is free for .tk, .ga, .ml and some other domains.

Managing DNS entries

After getting a domain, go to My Domains section(or similar using other providers):

../../_images/32.png

Click on Manage domain button and Manage Freenom Dns button(or similar using other providers).

../../_images/33.png

In DNS Management, add a new A record with target pointing to your ip address. Click save.

../../_images/34.png

Setting up server software(nginx)

Now, we will setup server software: nginx. It is widely used to manage domains and route requests. First, install nginx:

sudo apt install nginx

It will now run, if you open your ip address of the server(without specifying port, like 142.93.110.169 instead of 142.93.110.169:8000), you’ll see welcome from nginx page.

Setting up SSL and configuring nginx

To set up ssl certificates and create initial configuration for your domain, you’ll need to install certbot. Certbot is used to automatically renew your ssl certificates, plus it also creates initial nginx configuration for your domain. Let’s install it by typing(taken from official docs of certbot):

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python-certbot-nginx

Now, let’s create your ssl certificate. If it will fail, you should probably wait a few minutes till DNS changes you made will apply.

After that, run:

sudo certbot --nginx -d yourdomain.tld

Where yourdomain.tld is your domain, in my case it is testststs.tk. It will ask your for email to remind you when your ssl certificate expires or when some actions are required to renew it. When it asks about adjusting webserver configuration, answer 2(forward all traffic to https).

Now, we’ll need to edit nginx config(this assumes you have already installed joe from previous parts):

cd /etc/nginx/sites-enabled
joe default
../../_images/35.png

Now, find a server {} block, which will have server_name yourdomain.tld line in it, like on the screen, and replace existing line inside location / block with proxy_pass http://localhost:8000;. After that, use Ctrl+K+X to save the file, run sudo rm default~ to remove cached files(known issue with joe and nginx), and run sudo nginx -t to check for syntax errors.

If it reports some errors, contact us in our telegram group.

Now, restart nginx to apply your new configuration:

sudo systemctl reload nginx

Now, you can open your domain in browser, and see bitcart working with ssl certificate!

../../_images/36.png

Now, that’s all for my guide about setup of bitcart on digitalocean.

Addition: Small User guide

Creating a wallet

When you login at bitcart, to start you will need to create a wallet, so head to /wallets page, press on create wallet button, insert it’s name and xpub.

../../_images/37.png

Xpub is extended public key. You can find it in your wallet.

Then, press ok and your wallet will be added. You can create multiple wallets. If you click on wallet, you will be able to see all it’s transactions on the right. One Wallet can be used with multiple stores.

Creating a store

Next step is creating a store. Head to /stores page, here you can see list of active stores. Create one, note that name and wallet fields are required.

../../_images/38.png

Domain and template are store-specific things which will be explainted later, as they aren’t implemented yet. You can contact us in our group to know some details about future updates.

With stores you’ll be able to create products and display it on your frontpage, categorize it, and other.

Other useful tips

If you need to update bitcart, use the provided ./update.sh script. You’ll need to restart bitcart for changes to take place.

../../_images/updating.png

Conclusion

This is the end of tutorial, it is quite big, but that’s because of amount of images I have taken. I hope you found this guide useful. If you still have any questions, contact us in our telegram group. This guide will be edited with new details soon, as soon as we will add new things. Installation will soon become even easier.