How to install QuesCheetah in your local environment

This tutorial is based on Ubuntu Server 14.04 environment. In this tutorial we are going to deal with the simplest way to install QuesCheetah.

1. Install python version 3+

QuesCheetah is build with Python version 3.4.2. On Ubuntu 14.04 Python 3.4 is installed by default. If you are in diffent environment, Python official website is good reference to check.

Download here

After all the install process ends, confirm the version you installed with following command.

ubuntu@ip-172-31-19-130:~$ python3 -V
Python 2.7.6

2. Install git

Before we install Git, update all pre-installed packages.

ubuntu@ip-172-31-19-130:~$ sudo apt-get update
ubuntu@ip-172-31-19-130:~$ sudo apt-get install git

3. Clone QuesCheetah project in a directory

Make a new directory for our project.

ubuntu@ip-172-31-19-130:~$ sudo mkdir -p /var/www/QuesCheetah

Move to the new directory and Let's get all source files we need.

ubuntu@ip-172-31-19-130:~$ cd /var/www/QuesCheetah/
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo git clone https://github.com/mingkim/QuesCheetah.git .
Cloning into '.'...
remote: Counting objects: 1777, done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 1777 (delta 79), reused 36 (delta 36), pack-reused 1638
Receiving objects: 100% (1777/1777), 1.55 MiB | 571.00 KiB/s, done.
Resolving deltas: 100% (1060/1060), done.
Checking connectivity... done.

We can see that all files are now in place!

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ ls
bin         Dockerfile  main       NOTICE.txt    QuesCheetah  requirements.txt
circle.yml  LICENSE.md  manage.py  package.json  README.md    vote

4. Install MySQL Database and create our database

QuesCheetah uses MySQL database for default. But you can use any database you want like Sqlite, PostgreSQL... etc. We recommand to use MySQL version 5.5.

If you enter following command to install MySQL-5.5,

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo apt-get install mysql-server-5.5

The screen like this will popup, image

As our default password is "audwn8593", enter this word and in the next screen we need to enter this again for confirmation.

Enter the following command to check our mysql process is now running.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo netstat -tap | grep mysql
tcp        0      0 localhost:mysql         *:*                     LISTEN      12077/mysqld

Now let's connect to mysql server and make a database that our datas will be saved in. Since our default database name is "qc", create a database named "qc".

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ mysql -uroot -p
Enter password:   /*audwn8593*/
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> create database qc;
Query OK, 1 row affected (0.00 sec)

Exit MySQL client with "exit" command and move to next section.

5. Install all the libraries/packages we need

QuesCheetah needs some libraries to execute. First of all we need to install some dev libraries for installing other moudles correctly.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo apt-get install libmysqlclient-dev
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo apt-get install libmemcached-dev

And now we are going to install all python packages in requirements.txt file. We recommand to use "virtualenv" library. But in this time we just skipped that step.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo apt-get install python3-pip
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo pip3 install -r requirements.txt

6. Install SystemJS for frontend modulation.

This is our last section. SystemJS and jspm is used for module loading and package management each. QuesCheetah used several feature of these for modulating frontend script files and combining HTML, CSS files in one JavaScript file.

SystemJS and jspm is installed through npm. So we need to install npm first.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo apt-get install npm

Install SystemJs and other important modules. You can check what are installed with package.json file.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo npm install

After that, we need to install jspm and make jspm to use our Systemjs config file.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo npm install jspm -g
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah/QuesCheetah/static/js$ sudo ln -s /usr/bin/nodejs /usr/bin/node
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ sudo jspm install

All the installation process has been ended. QuesCheetah has a two setting file. One is local setting file for development environment, the other one is production setting file. We can choose what we want to use by making a envrionment variable. Make a variable named "DJANGO_SETTINGS_MODULE" with the value "QuesCheetah.settings.local". Since this tutorial used AWS EC2 instance for test and have to connect externally, we added an option "0.0.0.0:8000". If you use your own machine, you may not need this option.

ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ export DJANGO_SETTINGS_MODULE=QuesCheetah.settings.local
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ python3 ./manage.py migrate
ubuntu@ip-172-31-19-130:/var/www/QuesCheetah$ python3 ./manage.py runserver 0.0.0.0:8000

So, you can login with your superuser account and everything is all ready to go. Try to create questions and answers. If you have some feedbacks for us, please contact me by github. Thank you for reading! image