Share this post
FaceBook  Twitter  

1. Introduction

Question2Answer (Q2A) is a popular open source Q&A solution, currently in use on thousands sites world-wide in 40 languages. It is built on the standard PHP/MySQL platform, and runs safe and fast. A Q&A engine helps you to create an online community to share knowledge.

People with questions quickly get the answers they need. The community dynamic is enriched by commenting, voting, notifications, user points and rankings.

In this guide we will show you how to install this popular software on LAMP ( Linux Apache MySQL PHP). Operating system used will be Ubuntu 12.04.1 LTS.


Before we start, here are few points you should be aware of and configure:

  • question2answer.local - our hostname for a local installation
  • edit you /etc/hosts file or DNS to point to question2answer.local as your LAMP server where the actual installation of Question2Answer will reside.

2. Prerequisites installation

As a start we need to install all package prerequisites. This can be accomplished with the following command.

$ sudo apt-get install libapache2-mod-php5 php5-mysql mysql-server zip

In case that you have not have MySQL database installed already you will be prompted for a root password. This password will be used later on when we will create a new MySQL database to be used for question2answer installation.

3. Download and unzip Q2A

Next, download and unzip question2answer source files into /var/www directory. Feel free to change directory name to suit your environment. The command below will download question2answer source files, unzip them in /var/www and change the owner of the entire directory to apache2 user www-data.

$ cd /var/www/
$ sudo wget

All what remains is to unzip and change the owner:

$ sudo unzip
$ sudo chown -R www-data.www-data /var/www/question2answer

4. Configure Apache2 Web server

In the next step we need to configure a new apache site to point to the /var/www/question2answer directory. This can be easily done be making a modified copy of a default site:

$ cd /etc/apache2/sites-available
$ sudo sh -c 'sed "s/www/www\/question2answer/g" default > question2answer'

Restart apache2 webserver:

$ sudo a2ensite question2answer
$ sudo service apache2 reload

5. Create Database

In this step we will create a MySQL database to be used with question2answer. For this we will create the following:

  • MySQL database question2answer
  • MySQL user: q2a with password: q2a-pass

In this step you will need a root password to MySQL database. User name, database name and password are listed here as examples. Feel free to choose your own:

$ sudo mysql -p
Enter password:

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

mysql> CREATE USER 'q2a'@'localhost' IDENTIFIED BY 'q2a-pass';
Query OK, 0 rows affected (0.00 sec)

    -> on question2answer.* to q2a@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> quit

6. Configure question2answer

Almost there! Now, we need to create a question2answer configuration file and alter it to include database credentials. First, create copy of the sample configuration file:

$ cd /var/www/question2answer/
$ sudo cp qa-config-example.php qa-config.php

At this stage use your favorite text editor and amend a configuration file qa-config.php to include:

        define('QA_MYSQL_HOSTNAME', '');
        define('QA_MYSQL_USERNAME', 'q2a');
        define('QA_MYSQL_PASSWORD', 'q2a-pass');
        define('QA_MYSQL_DATABASE', 'question2answer');

7. question2answer installation

Everything should be now ready for the actual question2answer installation. At this point you either need to change your DNS settings to point to this new installation or simply alter the /etc/hosts file on your local box with an appropriate server IP address where question2answer script is hosted. For example:       question2answer.local

When done, navigate to http://question2answer.local URL using your browse and conclude the installation of question2answer with a few self-explanatory steps.

LAMP installation of Question2Answer on Ubuntu Linux


Who are we? is not affiliated with any local or international company, nor is it a recruitment or employment agency. We specialise in Linux based careers and closely related Information Technology fields by providing careers advice and latest employment opportunities.


You can also get involved in the LinuxCareer project by participating on our FORUM or SUBMITTING A LINUX ARTICLE. We offer a range of privileges to our authors and good company.