Setting Up Askbot on CentOS 8: A Guide to Installing with Nginx and Securing with Let’s Encrypt

Askbot is a free, open-source, and highly-customizable question-and-answer forum software written in Python and Django. It is simple, lightweight, and closely resembles other popular forum software like StackOverflow and Yahoo! Answers. Askbot boasts a variety of features including tags and categories, email notifications, a karma-based system, voting, content moderation, and more.

This tutorial will guide you through installing Askbot forum software on CentOS 8 with Let’s Encrypt SSL.

Prerequisites

  • A server running CentOS 8.
  • Root access configured on your server.

Install Required Dependencies

Start by installing the necessary dependencies for your system.

First, install the “Development Tools” with the command:

dnf group install 'Development Tools'

Next, install the EPEL repository and other Python dependencies using:

        dnf install epel-release -y
        dnf install python2-pip python2-devel python2-six -y

With all required packages installed, you can proceed to the next step.

Install and Configure PostgreSQL

Askbot utilizes PostgreSQL for data storage. Begin installation with:

dnf install postgresql-server postgresql-devel postgresql-contrib -y

Initialize the database:

postgresql-setup initdb

Next, start the PostgreSQL service and enable it to start on boot:

        systemctl start postgresql
        systemctl enable postgresql

Login to the PostgreSQL shell and set up the database:

        su - postgres
        psql

Create a database and user for Askbot:

        create database askbot;
        create user askbot with password 'password';

Grant privileges to the new user:

grant all privileges on database askbot to askbot;

Exit PostgreSQL shell:

\q

Edit the PostgreSQL configuration to set user authentication:

nano /var/lib/pgsql/data/pg_hba.conf

Replace “peer” with “md5” as shown:

    local   all             all                                    md5  
    host    all             all             127.0.0.1/32           md5  
    host    all             all             ::1/128                md5  

Restart PostgreSQL to apply changes:

systemctl restart postgresql

Install and Configure Askbot

Create an Askbot system user:

        useradd -m -s /bin/bash askbot
        passwd askbot

Add the Askbot user to the wheel group for sudo access:

usermod -a -G wheel askbot

Install Python virtualenv:

pip2 install virtualenv six

Switch to Askbot user and create a virtual environment:

        su - askbot
        virtualenv askbot

Activate the virtual environment:

        cd askbot
        source bin/activate

Install Askbot and dependencies:

        pip2 install six==1.10.0
        pip2 install askbot psycopg2

Create and set up your Askbot application:

        mkdir myapp
        cd myapp
        askbot-setup

Follow the prompts, selecting PostgreSQL, and enter the respective database details. Generate static files and initialize the database:

        python manage.py collectstatic
        python manage.py syncdb

Install and Configure uWSGI

Install uWSGI:

pip2 install uwsgi

Create a uWSGI configuration file:

nano /etc/uwsgi/sites/askbot.ini

Use the following configuration:

    [uwsgi]
    chdir = /home/askbot/askbot/myapp
    home = /home/askbot/askbot
    static-map = /m=/home/askbot/askbot/myapp/static
    wsgi-file = /home/askbot/askbot/myapp/django.wsgi
    master = true
    processes = 5
    # Run Askbot under a socket file
    socket = /run/uwsgi/askbot.sock
    chmod-socket = 664
    uid = askbot
    gid = nginx
    vacuum = true
    # uWSGI Log file
    logto = /var/log/uwsgi.log

Create a Systemd Service File for uWSGI

Create a systemd service file for uWSGI:

nano /etc/systemd/system/uwsgi.service

Add the following configuration:

    [Unit]
    Description=uWSGI service

    [Service]
    ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown askbot:nginx /run/uwsgi'
    ExecStart=/bin/uwsgi --emperor /etc/uwsgi/sites
    Restart=always
    KillSignal=SIGQUIT
    Type=notify
    NotifyAccess=all

    [Install]
    WantedBy=multi-user.target

Reload the systemd daemon:

systemctl daemon-reload

Install and Configure Nginx

Install Nginx with:

dnf install nginx -y

Create a virtual host configuration for Askbot:

nano /etc/nginx/conf.d/askbot.conf

Use the configuration:

    server {
         listen 80;
         server_name askbot.linuxbuz.com;
         location / {
         include         uwsgi_params;
         uwsgi_pass      unix:/run/uwsgi/askbot.sock;
         }
    }

Start and enable Nginx and uWSGI:

        systemctl start nginx
        systemctl enable nginx
        systemctl start uwsgi
        systemctl enable uwsgi

Secure Askbot with Let’s Encrypt SSL

Install the Certbot utility for Let’s Encrypt SSL:

        wget https://dl.eff.org/certbot-auto
        mv certbot-auto /usr/local/bin/certbot-auto
        chown root /usr/local/bin/certbot-auto
        chmod 0755 /usr/local/bin/certbot-auto

Obtain and install an SSL certificate:

certbot-auto --nginx -d askbot.linuxbuz.com

Configure Firewall and SELinux

Open HTTP and HTTPS services on the firewall:

        firewall-cmd --permanent --add-service=http
        firewall-cmd --permanent --add-service=https
        firewall-cmd --reload

Disable SELinux for Askbot by editing the /etc/selinux/config file and setting:

    SELINUX=disabled

Restart your system to apply changes.

Access Askbot

Open your browser and visit https://askbot.linuxbuz.com to access Askbot. You will encounter an interface similar to this:

Askbot web interface

Click on the Sign In button to log in:

Askbot sign-in

Enter your Askbot admin username and password to access the dashboard:

Ask questions in Askbot

Conclusion

Congratulations! You have successfully installed and configured the Askbot forum on CentOS 8 and secured it with Let’s Encrypt SSL. You can now start creating a question-and-answer community using Askbot.

FAQ

What is Askbot?

Askbot is an open-source question-and-answer forum software designed to resemble platforms like StackOverflow and Yahoo! Answers. It is written in Python and Django and offers a range of features for community engagement and moderation.

Why use PostgreSQL with Askbot?

PostgreSQL is a powerful, open-source object-relational database system that offers robust functionality and performance. It’s ideal for use with Askbot due to its reliability and scalability, ensuring efficient data storage and retrieval.

Is it necessary to disable SELinux for Askbot?

Disabling SELinux may be necessary if you encounter permission issues with Askbot. However, it’s generally advisable to configure SELinux properly for enhanced security, adjusting only the necessary permissions for Askbot to function correctly.

How does Let’s Encrypt SSL enhance security?

Let’s Encrypt SSL provides HTTPS encryption, which secures data transmitted between the server and clients. This encryption is crucial for protecting user data and enhancing the overall security of your Askbot site.