We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install Askbot on Ubuntu 20.04|18.04 with Let’s Encrypt SSL

Learn how to – Install Askbot on Ubuntu 20.04|18.04 with Let’s Encrypt SSL.

In this guide, we’re going to look at How to Setup Askbot Questions and Answers Framework on Ubuntu 20.04|18.04. Askbot is an open source question and answers web forum with a look similar to StackOverflow. Askbot is based on Django framework and most parts are written in Python programming language with some good features like a karma-based system, voting, and content moderation.

Askbot is used by Ask-FedoraProject and Ask-OpenStack projects to enable its users to ask questions and let other members of the community contribute.

In our installation of Askbot on Ubuntu 20.04|18.04, we will setup below prerequisites:

  • Database server – MySQL/MariaDB/PostgreSQL
  • uWSGI
  • Web Server – Nginx

Step 1: Install Askbot Dependencies

Start by installing all required dependencies, this will be python packages and pip package manager.

Update and upgrade system packages:

sudo apt update
sudo apt upgrade -y

Install python dependencies:

Ubuntu 20.04:

sudo apt install -y python3-dev python3-setuptools python3-pip libmysqlclient-dev

Ubuntu 18.04:

sudo apt install -y python-dev python-setuptools python-pip libmysqlclient-dev

Step 2: Install and Configure Database

For a database server, we’ll use MariaDB database server. This can be installed with the commands below:

sudo apt update
sudo apt install mariadb-server -y

Secure your database server installation:

$ sudo mysql_secure_installation

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Update authentication plugin to enable login as root user with password:

$ sudo mysql -u root
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

Once the database server has been installed, create a database and associated user for Askbot:

$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 59
Server version: 10.3.25-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE askbot_db;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> CREATE USER askbot@localhost IDENTIFIED BY 'StrongDBPassw0rd';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON askbot_db.* TO askbot@localhost;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> EXIT

Step 3: Install and Configure Askbot

Now that we have installed the packages we need to install Askbot, and we have a database ready, let us install Askbot application. We will use Python Virtualenv for this.

Start by creating askbot user:

$ sudo adduser askbot
Adding user `askbot' ...
Adding new group `askbot' (1000) ...
Adding new user `askbot' (1000) with group `askbot' ...
Creating home directory `/home/askbot' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for askbot
Enter the new value, or press ENTER for the default
Full Name []: 
Room Number []: 
Work Phone []: 
Home Phone []: 
Other []: 
Is the information correct? [Y/n] y
$ id askbot
uid=1000(askbot) gid=1000(askbot) groups=1000(askbot)

Add askbot user to sudo group:

sudo usermod -aG sudo askbot

Install virtualenv:

# Ubuntu 20.04
$ sudo pip3 install virtualenv

# Ubuntu 18.04
$ sudo pip install virtualenv

Create a directory for Askbot content:

sudo mkdir /srv/askbot
sudo chown askbot:askbot /srv/askbot/
sudo su - askbot
cd /srv/askbot/

After installing virtualenv package, create a Virtual environment for askbot:

$ virtualenv venv
New python executable in /srv/askbot/venv/bin/python
Installing setuptools, pip, wheel...done.

Source the env to start using it:

$ cd venv/
askbot@ubuntu:/srv/askbot/venv$ source bin/activate
(venv) askbot@ubuntu:/srv/askbot/venv$

Then install askbot and mysql python module:

# Ubuntu 20.04
pip3 install askbot gunicorn mysqlclient mysql-python

# Ubuntu 18.04
pip2 install askbot gunicorn mysqlclient mysql-python

Setup Askbot:

(venv) askbot@node-02:/srv/askbot/venv$ mkdir askbot-app
(venv) askbot@node-02:/srv/askbot/venv$ cd askbot-app

Run the command askbot-setup to install askbot.

(venv) askbot@node-02:/srv/askbot/venv/askbot-app$ askbot-setup

Deploying Askbot - Django Q&A forum application
Problems installing? -> please email admin@askbot.org

To CANCEL - hit Ctr-C at any time

Enter directory path (absolute or relative) to deploy
askbot. To choose current directory - enter "."
> .

Please select database engine:
1 - for postgresql, 2 - for sqlite, 3 - for mysql, 4 - oracle
type 1/2/3/4: 3

Please enter database name (required)
> askbot_db

Please enter database user (required)
> askbot

Please enter database password (required)
> Password
Copying files: 
* __init__.py 
* manage.py 
* urls.py 
* django.wsgi 
Creating settings file
settings file created

copying directories: * doc
* cron
* upfiles

Done. Please find further instructions at http://askbot.org/doc/

Generate static files to AskBot installation directory:

$ python manage.py collectstatic

If you get an error like “TypeError: Error when calling the metaclass bases“, there is a fix for it. You need to install six version 1.10.0. Uninstall the latest version and install v1.10.0

(venv) askbot@node-02:/srv/askbot/askbot-app$ pip uninstall six 
(venv) askbot@node-02:/srv/askbot/askbot-app$ pip install six==1.10.0

When done, generate static files to AskBot installation directory:

$ python manage.py collectstatic

Type ‘yes‘ and press Enter to continue to finish generation of files.

Then run makemigrations and migrate commands

(venv) askbot@node-02:/srv/askbot/askbot-app$ python manage.py makemigrations
WARNING!!! You are using a 'locmem' (local memory) caching backend,
which is OK for a low volume site running on a single-process server.
For a multi-process configuration it is neccessary to have a production
cache system, such as redis or memcached.

With local memory caching and multi-process setup you might intermittently
see outdated content on your site.

System check identified some issues:

django_authopenid.UserPasswordQueue.user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.
group_messaging.SenderList.recipient: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.
Migrations for 'askbot':
- Change Meta options on activity
- Change Meta options on award
- Change Meta options on badgedata
- Change Meta options on favoritequestion
- Change Meta options on postflagreason
- Change Meta options on postrevision
- Change Meta options on replyaddress
- Change Meta options on repute
- Change Meta options on threadtogroup
- Change Meta options on vote
- Alter field frequency on emailfeedsetting
- Alter field primary_language on userprofile

Generate the MySQL database with the optionmigrate.

(venv) askbot@node-02:/srv/askbot/askbot-app$ python manage.py migrate

You can also use:

$ python manage.py syncdb
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
You have installed Django's auth system, and don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'askbot'): askbot
Email address: askbot@ownyourlife.com.ng
Password (again): 
Superuser created successfully.

When the script asks you if you want to create a superuser, answer yes if you want to create one. By default Askbot sets admin status(superuser) for the first user created automatically but also supports this form.

Test Askbot installation using:

(venv):/srv/askbot/askbot-app$ python manage.py runserver

Access your server IP and port 8080. If everything is okay, you should get to its dashboard below:

Step 5: Install and Configure uWSGI & Nginx

Install uWSGI from apt:

sudo apt-get install uwsgi

Create uwsgi configuration file for Askbot:

$ sudo vim /etc/uwsgi/apps-enabled/askbot.ini

Add content:


# uwsgi configurations
master = true
processes = 5
uid = www-data
listen.owner = www-data
listen.group = www-data

# App configurations
socket = /srv/askbot/askbot.sock
chown-socket = www-data:www-data
chmod-socket = 664
vacuum = true
die-on-term = true
logto = /var/log/uwsgi.log
log-master-stream = true

Modify the file accordingly then save it.

Install nginx:
sudo apt-get install nginx

Restart uwsgi service with www-data  as socket file owner:

$ sudo systemctl restart uwsgi

Install certbot for generating Letsencrypt SSL Certificate:

sudo apt update
sudo apt install certbot

Stop Nginx service:

sudo systemctl stop nginx

Generate Letsencrypt SSL certificate:

export DOMAIN='ask.ownyourlife.com.ng'
export EMAIL="webmaster@ownyourlife.com.ng"
sudo certbot certonly --standalone -d $DOMAIN 
  --preferred-challenges http --agree-tos -n -m $EMAIL 

Don’t forget to set correct domain and email address.

If successful, certbot will give you a successful message:

Cleaning up challenges
 - Congratulations! Your certificate and chain have been saved at:
   Your key file has been saved at:
   Your cert will expire on 2018-09-28. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Create Nginx configuration file:

$ sudo vim /etc/nginx/conf.d/askbot.conf

Ensure you replace variables with your valid values then save the file.

# Askbot Nginx configuration
# configuration for https
server {
        listen 443 ssl http2;
        server_name ask.ownyourlife.com.ng www.ask.ownyourlife.com.ng;

        ssl on;
        ssl_certificate /etc/letsencrypt/live/ask.ownyourlife.com.ng/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/ask.ownyourlife.com.ng/privkey.pem;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        location /static {
          alias /srv/askbot/askbot-app/static;

        location / {
          include uwsgi_params;
          uwsgi_pass unix:/srv/askbot/askbot.sock;

# http to https redirect
server {
        listen 80;
        server_name ask.ownyourlife.com.ng www.ask.ownyourlife.com.ng;
        return    301 https://$server_name$request_uri;

Confirm that the syntax is okay:

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart that both uwsgi and nginx services after making the change.

$ sudo systemctl restart uwsgi nginx


Your Cart is Empty

Back To Shop