Installing Answer on Ubuntu Server

Answer is a cloud-based Q&A platform that is designed to help teams collaborate and stay organized. In this tutorial, we will discuss the steps you need to follow to install Answer on Ubuntu Server.

Prerequisites

Before proceeding with the installation, you will need:

Step 1: Update Packages

Before we begin the installation process, we need to make sure all our packages are up to date. To do this, run the following command:

sudo apt-get update && sudo apt-get upgrade

Step 2: Install Necessary Packages

Answer requires several packages to work correctly. To install them, run the following command:

sudo apt-get install -y curl nodejs npm nginx postgresql-13 postgresql-client-13 git

Step 3: Install Node.js

Answer is built on Node.js. We will install the latest version of Node.js using NVM (Node Version Manager). Run the following command to install NVM:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Source the NVM script to start using it:

source ~/.bashrc

To install the latest version of Node.js, run the following command:

nvm install node

Step 4: Set Up PostgreSQL Database

We will use PostgreSQL as our database. To create a new PostgreSQL database user and database, run the following commands:

sudo -u postgres createuser answer
sudo -u postgres createdb answerdb --owner=answer

Step 5: Clone Answer Repository

Clone the Answer repository to your working directory using the following command:

git clone https://github.com/namara-io/answer_backend.git answer

Move to the Answer directory:

cd answer

Step 6: Install Answer Dependencies

Install the Answer dependencies using the following command:

npm install

Step 7: Configure Answer

Copy the config/example.env file to .env and modify as required:

cp config/example.env .env

Update the database connection configuration:

DB_NAME=answerdb
DB_USER=answer
DB_PASSWORD=<your-password>
DB_HOST=localhost
DB_PORT=5432

Step 8: Start Answer Server

To start the Answer server, run the following command:

npm start

Step 9: Configure Nginx

We will use Nginx as our reverse proxy server. Create a new Nginx configuration file:

sudo nano /etc/nginx/sites-available/answer

Paste the following configuration into the file:

server {
  listen 80;
  listen [::]:80;

  server_name answer.example.com;

  location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }

  listen [::]:443 ssl http2; # managed by Certbot
  listen 443 ssl http2; # managed by Certbot
  ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem; # managed by Certbot
  include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

Replace the server_name and ssl_certificate and ssl_certificate_key paths with your own domain name and SSL certificate.

Create a symlink of the file you just created in the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/answer /etc/nginx/sites-enabled

Remove the default Nginx configuration file:

sudo rm /etc/nginx/sites-enabled/default

Verify the Nginx configuration:

sudo nginx -t

Reload Nginx:

sudo systemctl reload nginx

Step 10: Access Answer Dashboard

Open a web browser and navigate to the Answer dashboard using your domain name, for example:

http://answer.example.com

Conclusion

That's it! You now have Answer installed on your Ubuntu Server. You can now begin configuring and using Answer for your Q&A needs.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!