• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar
  • Skip to footer
WebSetNet

WebSetNet

Technology News

  • Technology News
    • Mobile
    • Games
  • Internet Marketing
  • System Admin
    • Windows
    • Linux
    • Mac & Apple
    • Website Scripts
      • Wordpress

How to Install and Configure Askbot with Nginx on CentOS 7

August 5, 2020 by Martin6

How to Install and Configure Askbot with Nginx on CentOS 7

Askbot is an open source software for creating Q&A forums based on Python Django Framework. It’s basically a Q&A system like StackOverflow, Yahoo Answers, and others. Created by Mike Chan and Sailing Cai on 2009, and it’s easy to install and configure on Linux systems like Ubuntu and CentOS. Many large open source software projects like Fedora and LibreOffice are using it.

In this tutorial, we will show you how to install Askbot Python Django application using uWSGI and Nginx web server on CentOS 7 system. As for database, we will be using PostgreSQL for Askbot installation.

What we will do

  1. Install dependencies
  2. Install and configure PostgreSQL
  3. Install and configure Askbot
  4. Install and configure uWSGI
  5. Install and configure Nginx Webserver
  6. Test the setup

Prerequisites

  • CentOS 7 Server
  • Root privileges

Step 1 – Install dependencies

In this step, we will install some packages that are needed for successful Askbot installation. These include ‘Development Tools’, Epel repository, and some python-related tools (for managing Python packages). So let’s begin.

First, install CentOS ‘Development Tools’ with yum group command below.

yum group install ‘Development Tools’

Then install the Epel repository.

yum -y install epel-release

And finally install the python packages, including python pip, python-devel and python six.

yum -y install python-pip python-devel python-six

Installing python

Step 2 – Install and configure PostgreSQL

Now we need PostgreSQL database, which is available in the CentOS repository. In this section, we will discuss how you can install PostgreSQL database, change the postgres password user, create a new user and database for the Askbot installation, and finally, change the postgres authentication config.

So let’s start with installing PostgreSQL from the repository using the yum command below.

yum -y install postgresql-server postgresql-devel postgresql-contrib

Once the installation is complete, we need to initialize the database, which you can do using the command below.

postgresql-setup initdb

Moving on, start postgres and enable it to launch automatically at the boot time.

systemctl start postgresql
systemctl enable postgresql

At this point, the PostgreSQL database should be installed. Next, we need to reset the postgres user password. For this, first login as ‘postgres’ user and access the psql command line tool.

su – postgres
psql

And then give the postgres user a new password.

password postgres

Now, create a new database and user for Askbot. For example, we want to create a new user ‘hakaselabs‘ with password ‘hakase123‘, and the database named ‘askbotdb‘. The following postgres queries will help us create all of these.

create database askbotdb;
create user hakaselabs with password ‘hakase123’;
grant all privileges on database askbotdb to hakaselabs;

Install PostgreSQL

So now, a database and user for Askbot installation have been created. The next step is to edit the postgres configuration for authentication setup, which you can do by heading to the ‘pgsql/data’ directory and editing the ‘pg_hba.conf’ file with vim.

cd /var/lib/pgsql/data/
vim pg_hba.conf

Once inside the file, change all authentication to md5, as shown below.

local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Configure PostgreSQL

Now, save and exit the file, and then restart the postgres service.

systemctl restart postgresql

So by now, the PostgreSQL database has been installed; database for the Askbot installation has been created; and the postgres user authentication method has been changed to md5.

Step 3 – Install and configure Askbot

In this step, we will discuss the installation and configuration of Askbot. We will install Askbot under a user named ‘askbot’, and using the virtualenv python. So let’s begin.

Firstly, create a new user ‘askbot’ and give the user a new password.

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

Then add the ‘askbot’ user to the ‘wheel’ group for sudo command access (not sure what ‘sudo’ is? Learn more about it here).

usermod -a -G wheel askbot

Install AskBot

Now upgrade pip to the latest version and install the python virtualenv package.

pip install –upgrade pip
pip install virtualenv six

Install pip

Next. log in as ‘askbot’ user and create new python virtual environment ‘hakase-labs’ with virtualenv.

su – askbot
virtualenv hakase-labs/

Go to the ‘hakase-labs’ directory and activate the virtual environment for Askbot installation.

cd hakase-labs/
source bin/activate

Now install askbot and other python packages with pip command on ‘hakase-labs’ virtual environment.

pip install six
pip install askbot psycopg2

installing askbot

Next, create a new directory for the ‘Askbot’ project. Please make sure you don’t use ‘askbot’ as the directory name. In our case, for example, we created a new directory named ‘myapp’

mkdir myapp/

Go to the myapp directory and run the ‘askbot-setup’ command.

cd myapp/
askbot-setup

The ‘askbot-setup’ command will ask you certain things. For example, you will be asked about directory path to deploy Askbot – you can type ‘.’ and press Enter to continue. Similarly, when asked about database engine, type ‘1’ to use postgresql and press Enter. For database-related details, enter databasename as ‘askbotdb’, database user as ‘hakaselabs’, and password as ‘hakase123’.

configure the application

So Askbot is now installed on the ‘myapp’ directory. Now we need to generate Askbot Django static files and the database.

Run the command below to generate Askbot Django static files.

python manage.py collectstatic

When asked for confirmation, type ‘yes’ and press Enter.

python manage.py

Now, to generate the database, run syncdb as below.

python manage.py syncdb

You will be asked about creating the admin user and password. So when asked, type the username, email, and password for admin configuration.

Create admin user

So by now, Askbot has been installed, static files have been generated, and the database configuration has been completed.

You can test the Askbot installation with runserver command below.

python manage.py runserver 0.0.0.0:8080

Open your Web browser and type the server IP address, and you should see a page similar to the following:

Result in web browser

Step 4 – Install and configure uWSGI

We will be using uWSGI as service for the Askbot Django project. Specifically, we will be using uWSGI with Nginx web server for the Askbot installation. So let’s begin.

Firstly, install uWSGI using the pip command, as shown below.

sudo pip install uwsgi

After the installation is complete, create a new directory for the uWSGI virtual host files. For example, in our case, we created ‘/etc/uwsgi/sites’.

mkdir -p /etc/uwsgi/sites

Go to the newly-created directory and create new askbot uWSGI configuration with vim.

cd /etc/uwsgi/sites
vim askbot.ini

Paste the following configuration in the file.

[uwsgi]
# Project directory, Python directory
chdir = /home/askbot/hakase-labs/myapp
home = /home/askbot/hakase-labs/
static-map = /m=/home/askbot/hakase-labs/myapp/static
wsgi-file = /home/askbot/hakase-labs/myapp/django.wsgi
master = true
processes = 5
# Askbot will running under the sock file
socket = /run/uwsgi/askbot.sock
chmod-socket = 664
uid = askbot
gid = nginx
vacuum = true
# uWSGI Log file
logto = /var/log/uwsgi.log

That’s it. Save the file and exit from the editor.

Next, add new uWSGI service script file to the ‘/etc/systemd/system’ directory. Go to the directory and create the ‘uwsgi.service’ file with vim.

cd /etc/systemd/system/
vim uwsgi.service

Paste the following uWSGI service configuration in the file.

[Unit]
Description=uWSGI Emperor 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

Save and exit.

Now, reload systemd services and enable uWSGI to start automatically at the boot time.

systemctl daemon-reload
systemctl enable uwsgi

Reload services

So with this, uWSGI has been installed, and you should see it running as a service.

Step 5 – Install and configure Nginx webserver

So, Askbot is now installed, and it’s running under uWSGI sock file ‘askbot.sock’. In this step, we will be using Nginx web server as a reverse proxy for uWSGI application ‘Askbot’.

To begin with, install Nginx with the yum command.

yum -y install nginx

Now go to the Nginx ‘conf.d’ directory and create new virtual host file ‘askbot.conf’ with the vim editor.

cd /etc/nginx/conf.d/
vim askbot.conf

install nginx

Paste the following Askbot Nginx configuration in the file.

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

Save the file and exit from the editor. Now, test the configuration to make sure there is no error.

nginx -t

Next, start Nginx and uWSGI services.

systemctl start nginx
systemctl start uwsgi

And enable them to start automatically at the boot time.

systemctl enable nginx
systemctl enable uwsgi

test nginx config and restart nginx

So Nginx is now installed as a reverse proxy for uWSGI application ‘Askbot’.

Step 6 – Test the setup

Open your web browser and visit the Askbot domain name: askbot.me, and you will get to see the home page, as shown below.

askbot domain

Here’s the Askbot user login page:

askbot login

Askbot user dashboard:

askbot dashboard

Askbot admin setting:

askbot admin dashboard

Askbot Django admin login:

Django admin login

Askbot Django admin dashboard:

Django admin dashboard

So the Q&A system application ‘Askbot’ has been successfully installed with uWSGI and Nginx web server on CentOS 7 server.

Source

Related posts:

  1. How to Install Askbot on CentOS 7
  2. How to Build NGINX from source on Ubuntu 18.04 LTS
  3. Askbot: How To Install and Configure the Questions and Answers Framework on CentOS 7
  4. How to Install WordPress with HHVM and Nginx on CentOS 7
  5. Install and Configure LEMP Stack in Debian 9
  6. Install Taiga.io Agile Project Management Software on Ubuntu 16.04
  7. How to Install Restyaboard on CentOS 7
  8. How to Install Magento 2.1 on CentOS 7
  9. Install Nginx with ngx_pagespeed on CentOS 7
  10. How to Install SuiteCRM with Nginx on CentOS 7

Filed Under: Uncategorized

Primary Sidebar

Trending

  • How to fix Windows Update Error 80244019
  • Windows 10 Update keeps failing with error 0x8007001f – 0x20006
  • How To Change Netflix Download Location In Windows 10
  • Troubleshoot Outlook “Not implemented” Unable to Send Email Error
  • How do I enable or disable Alt Gr key on Windows 10 keyboard
  • How To Install Android App APK on Samsung Tizen OS Device
  • 3 Ways To Open PST File Without Office Outlook In Windows 10
  • FIX: Windows Update error 0x800f0986
  • How to Retrieve Deleted Messages on Snapchat
  • Latest Samsung Galaxy Note 20 leak is a spec dump revealing key features
  • Install Android 7.0 Nougat ROM on Galaxy Core 2 SM-G355H
  • 192.168.1.1 Login, Admin Page, Username, Password | Wireless Router Settings
  • Websites to Watch Movies Online – 10+ Best Websites Without SignUp/Downloading
  • How to Backup SMS Messages on Your Android Smartphone
  • How to delete a blank page at the end of a Microsoft Word document
  • Fix: The Disc Image File Is Corrupted Error In Windows 10
  • Android 11 Custom ROM List – Unofficially Update Your Android Phone!
  • Samsung Galaxy Z Fold 3 could be scheduled for June 2021, with S Pen support

Footer

Tags

Amazon amazon prime amazon prime video Apple Application software epic games Galaxy Note 20 Galaxy S22 Plus Galaxy S22 Ultra Google Sheets headphones Huawei icloud Instagram instant gaming ip address iPhone iphone 12 iphone 13 iphone 13 pro max macOS Microsoft Microsoft Edge Mobile app office 365 outlook Pixel 6 Samsung Galaxy Samsung Galaxy Book 2 Pro 360 Samsung Galaxy Tab S8 Smartphone speedtest speed test teams tiktok Twitter vpn WhatsApp whatsapp web Windows 10 Windows 11 Changes Windows 11 Release Windows 11 Update Windows Subsystem For Android Windows 11 Xiaomi

Archives

  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org