How to Install AskBot Encrypt SSL on Ubuntu 16.04

How to Install, Configure, and Run AskBot with Let’s Encrypt SSL on Ubuntu 16.04
How to Install, Configure, and Run AskBot with Let’s Encrypt SSL on Ubuntu 16.04

What is Askbot

Askbot is a commercial, open-source question and answer platform. StackOverflow and Yahoo Answers were the inspiration for Askbot. It has the same features, including karma points, upvotes, and downvotes. AskBot launched in 2009 and is used by LibreOffice, Fedora,, Sage, and others for their Q&A sections. It is written in Python on top of the Django platform.

How to Install AskBot Encrypt SSL on Ubuntu 16.04

In this tutorial, we’ll show you how to install, configure, and run AskBot and deploy with NGINX as a web server using PostgreSQL as a database server and LetsEncrypt as a free SSL certificate provider on your Ubuntu 16.04 server. Check out our Latest VPS Hosting tools and packages for scaling and startups. Let’s get started with the tutorial, and if you carefully follow the steps below, you should have AskBot installed on Ubuntu 16.04 in less than 10 minutes.

Install Dependencies

The first step is the installation of the required packages. Run the following command to install them:
apt-get install python-pip python-dev python-setuptools python-flup libpng12-dev zlib1g-dev libpng-dev libjpeg-dev build-essential

Install and configure PostgreSQL database

Install PostgreSQL from the Ubuntu package repository. You can do this using the following command:
sudo apt-get install -y postgresql postgresql-contrib
At this point, in order to configure local user authentication, you need to edit the pg_hba.conf file using a text editor, e.g., nano:
nano /etc/postgresql/9.5/main/pg_hba.conf
If you want to activate password authentication using an MD5 hash, then you should replace peer with md5 on this line:
local   all          all                  md5
Save and exit. You should restart the PostgreSQL service in order to enable automatic start at system boot and at the same time to enable these changes.
systemctl restart postgresql

systemctl enable postgresql
Create a new PostgreSQL database and user for Askbot installation. In this tutorial, a new database ‘askbot_db’ with username ‘askbot_user’ and password ‘YOUR_PASSWORD’ was created. You need to log in as the postgres user and access the PostgreSQL shell ‘psql’.
su - postgres

Using the next queries, you can create a new database named ‘askbot_db’ and a new user ‘askbot_user’ with password ‘YOUR_PASSWORD’.
create database askbot_db;

create user askbot_user with password 'YOUR_PASSWORD';

grant all privileges on database askbot_db to askbot_user;

Now, you have created a new PostgreSQL database for Askbot installation.

Install and Configure Askbot Django App

You have installed all the packages which are needed for the installation of Askbot, and you have created the PostgreSQL database. The next thing on your list is to install and configure Askbot. Now, for the installation of Askbot, a new user should be created, because the root user won’t be used for it. You need to create a new user, ‘askbot’, and give a new password to that user.
useradd -m -s /bin/bash askbot

passwd askbot
Then, you should add the askbot user to the sudo group using the usermod command.
usermod -a -G sudo askbot
You need to create a Symbolic link to /user/bin:
sudo ln -s /usr/local/bin/pip /usr/bin/
You have now created a new user. The next step is to update python-pip and install the virtualenv package. Using the following pip commands, you can install these packages.
pip install --upgrade pip

pip install virtualenv
At this point, you should log in as the ‘askbot’ user with the su command and install Askbot.
su - askbot
Next, we would need a new virtual environment for the installation of askbot, and we can create this with the virtualenv command.
virtualenv example_user
To activate the new virtual environment, use the following command:
source example_user/bin/activate
Next, you should install the Askbot Django app with pip, including psycopg2 for PostgreSQL database connections.
pip install askbot psycopg2
Now, you need to create a new directory for the Askbot Django app – we choose to use the name ‘my_app’. You should install Askbot in the created directory.
mkdir my_app/

cd my_app
Install Askbot using the following command:
You should only give the single ‘.‘ and press ‘Enter’ when asked about the Askbot installation directory. In a similar way, by choosing the number ‘1’, you can choose PostgreSQL for database config. Input the database name ‘askbot_db‘, username ‘askbot_user‘, and password ‘YOUR_PASSWORD‘.
pip install six==1.10
Using this command, you will generate a Django static files directory.
python collectstatic
In order to continue, type ‘yes’ and press Enter. With the use of the syncdb option, you can generate the PostgreSQL database.
python syncdb
You should type ‘yes’ and then type your admin user, email, and password when asked to create the admin user. Now you have installed Askbot on the system under the ‘askbot’ user virtual environment. If you want to test the installation of Askbot, you can run the runserver command below.
python runserver
If you want to check the Askbot page, you need to open your web browser and type the server IP with port 8080.

AskBot with Let’s Encrypt SSL

uWSGI supports applications based on Python, Perl, and Ruby. Here, we are going to use uWSGI with the Nginx web server for our Askbot installation. You can install uWSGI using the pip command below.
sudo pip install uwsgi
The next step is the creation of a new directory for the uWSGI site configuration ‘/etc/uwsgi/sites’.
mkdir -p /etc/uwsgi/sites

cd /etc/uwsgi/sites
You need to add a new uWSGI configuration file ‘askbot.ini’ to the ‘sites’ directory and then edit it with nano.
nano  askbot.ini
There, paste the following uWSGI configuration:

# Project directory, Python directory

chdir = /home/askbot/example_user/my_app

home = /home/askbot/example_user/

static-map = /m=/home/askbot/example_user/my_app/static

wsgi-file = /home/askbot/example_user/my_app/django.wsgi

master = true

processes = 5

# Askbot will running under the sock file

socket = /home/askbot/example_user/my_app/askbot.sock

chmod-socket = 664

uid = askbot

gid = www-data

vacuum = true

# uWSGI Log file

logto = /var/log/uwsgi.log

Install and configure Nginx to use SSL Certificates with AskBot

You have now installed Askbot and it’s running under the uWSGI sock file ‘askbot.sock’. At this point, we are going to use an Nginx web server as a reverse proxy for the uWSGI application Askbot. Using the apt command below, you can install Nginx from the repository.
apt-get install nginx
Now, using the pip command below, you can install LetsEncrypt.
pip install letsencrypt-nginx==0.7.0

certbot --nginx -d -d
Once you have completed the installation, don`t forget to add a new nginx virtual host file ‘askbot.conf’.
nano /etc/nginx/sites-available/askbot.conf
In it, you need to paste the following askbot nginx virtual host configuration:
server {

        listen 80;


        location / {

        include         uwsgi_params;

        uwsgi_pass      unix:/home/askbot/example_user/my_app/askbot.sock;


 listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/;

    ssl_certificate_key /etc/letsencrypt/live/;

    include /etc/letsencrypt/options-ssl-nginx.conf;

    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;


server {

    if ($host = {

        return 301 https://$host$request_uri;


        listen 80;


    return 404;


Save and exit. Next, with the creation of a symlink from the ‘askbot’ file to the ‘sites-enabled’ directory, you will enable the Askbot virtual host file.
ln -s /etc/nginx/sites-available/askbot.conf /etc/nginx/sites-enabled/askbot.conf
Run the following command if you want to test the nginx configuration:
nginx -t
That’s it! You have successfully installed the Nginx web server and configured it for the Askbot Python Django app. Here are a few hand-picked tutorial guides for you to read next: Share this Tutorial with your colleagues and cofounders as it will help them and make my countless hours of work count. Thanks!
Updated on 19 Sep 2018
Add a comment
Login for Comment