{"id":17111,"date":"2015-05-05T15:52:36","date_gmt":"2015-05-05T20:52:36","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=17111"},"modified":"2022-12-16T05:05:17","modified_gmt":"2022-12-16T11:05:17","slug":"install-question2answer-on-an-ubuntu-14-04-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-question2answer-on-an-ubuntu-14-04-vps\/","title":{"rendered":"Install Question2Answer on an Ubuntu 14.04 VPS"},"content":{"rendered":"
In this tutorial we will show you how to install Question2Answer on an Ubuntu 14.04 VPS with MariaDB, PHP-FPM and Nginx. Question2Answer is an open source question-answer system written in PHP, used by over 14,000 sites in 40 languages. This guide should work on other Linux VPS<\/a> systems as well but was tested and written for Ubuntu 14.04 VPS<\/a>.<\/p>\n <\/p>\n When the installation is complete, run the following command to secure your installation:<\/p>\n Next, we need to create a database for our Question2Answer installation.<\/p>\n Create a root directory for your web site and clone the git repository from github using the following commands:<\/p>\n Rename qa-config-example.php to qa-config.php.<\/p>\n Open qa-config.php in your text editor of choice and insert the MySQL details:<\/p>\n Installing PHP and Nginx is pretty easy, just run the following command:<\/p>\n Create a new PHP-FPM pool for your user:<\/p>\n Restart PHP-FPM<\/p>\n Create a new Nginx server block with the following content:<\/p>\n Activate the server block by creating a symbolic link :<\/p>\n Test the Nginx configuration and restart nginx:<\/p>\n That’s it. You have successfully installed your Question2Answer. For more information about Question2Answer, please refer to the Question2Answer<\/a> website.<\/p>\n Of course you don\u2019t have to do any of this if you use one of our Linux VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.<\/p>\n PS<\/span><\/strong>. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" In this tutorial we will show you how to install Question2Answer on an Ubuntu 14.04 VPS with MariaDB, PHP-FPM and … <\/p>\nLogin to your VPS via SSH<\/h4>\n
ssh user@vps<\/pre>\n
Update the system and install necessary packages<\/h4>\n
user@vps:~# sudo apt-get update && sudo apt-get -y upgrade\r\nuser@vps:~# sudo apt-get install python-software-properties software-properties-common git vim<\/pre>\n
Install MariaDB 10.0<\/h4>\n
user@vps:~# sudo apt-key adv --recv-keys --keyserver hkp:\/\/keyserver.ubuntu.com:80 0xcbcb082a1bb943db\r\nuser@vps:~# sudo add-apt-repository 'deb http:\/\/ftp.osuosl.org\/pub\/mariadb\/repo\/10.0\/ubuntu trusty main'\r\nuser@vps:~# sudo apt-get install mariadb-server<\/pre>\n
mysql_secure_installation<\/pre>\n
mysql -uroot -p\r\nMariaDB [(none)]> CREATE DATABASE q2a;\r\nMariaDB [(none)]> GRANT ALL PRIVILEGES ON q2a.* TO 'q2auser'@'localhost' IDENTIFIED BY 'q2auser_passwd';\r\nMariaDB [(none)]> FLUSH PRIVILEGES;\r\nMariaDB [(none)]> \\q<\/pre>\n
Clone the Question2Answer git repository<\/h4>\n
user@vps:~# mkdir -p ~\/yourQ2aSite.com\/{public_html,logs}\r\nuser@vps:~# git clone https:\/\/github.com\/q2a\/question2answer.git ~\/yourQ2aSite.com\/public_html<\/pre>\n
Question2Answer configuration<\/h4>\n
mv qa-config-example.php qa-config.php<\/pre>\n
vim ~\/yourQ2aSite.com\/public_html\/qa-config.php<\/pre>\n
define('QA_MYSQL_HOSTNAME', '127.0.0.1');\r\n define('QA_MYSQL_USERNAME', 'q2auser');\r\n define('QA_MYSQL_PASSWORD', 'q2auser_passwd');\r\n define('QA_MYSQL_DATABASE', 'q2a');\r\n<\/pre>\n
Install PHP-FPM and Nginx<\/h4>\n
user@myVPS:~# sudo apt-get install nginx php5-common php5-fpm php5-cli php5-mysqlnd<\/pre>\n
PHP-FPM configuration<\/h4>\n
user@vps:~# sudo tee \/etc\/php5\/fpm\/pool.d\/$(whoami).conf << EOF\r\n[$(whoami)]\r\nuser = $(whoami) \r\ngroup = $(whoami) \r\nlisten = \/var\/run\/php5-fpm-$(whoami).sock \r\nlisten.owner = $(whoami)\r\nlisten.group = $(whoami) \r\nlisten.mode = 0666 \r\npm = ondemand \r\npm.max_children = 5 \r\npm.process_idle_timeout = 10s; \r\npm.max_requests = 200 \r\nchdir = \/ \r\nEOF<\/pre>\n
user@vps:~# sudo service php5-fpm restart<\/pre>\n
Nginx configuration<\/h4>\n
user@vps:~# sudo tee \/etc\/nginx\/sites-available\/yourQ2aSite.com << EOF\r\nserver {\r\n server_name yourQ2aSite.com;\r\n listen 80;\r\n root $HOME\/yourQ2aSite.com\/public_html;\r\n access_log $HOME\/yourQ2aSite.com\/logs\/access.log;\r\n error_log $HOME\/yourQ2aSite.com\/logs\/error.log;\r\n index index.php;\r\n \r\n location \/ {\r\n try_files \\$uri \\$uri\/ \/index.php?qa-rewrite=\\$uri&\\$args;\r\n }\r\n \r\n location ~* \\.(?:ico|css|js|gif|jpe?g|png|ttf|woff)\\$ {\r\n access_log off;\r\n expires 30d;\r\n add_header Pragma public;\r\n add_header Cache-Control \"public, mustrevalidate, proxy-revalidate\";\r\n }\r\n \r\n location ~ \\.php\\$ {\r\n fastcgi_split_path_info ^(.+\\.php)(\/.+)\\$;\r\n fastcgi_pass unix:\/var\/run\/php5-fpm-$(whoami).sock;\r\n fastcgi_index index.php;\r\n include fastcgi_params;\r\n fastcgi_param SCRIPT_FILENAME \\$document_root\\$fastcgi_script_name;\r\n fastcgi_intercept_errors off;\r\n fastcgi_buffer_size 16k;\r\n fastcgi_buffers 4 16k;\r\n }\r\n \r\n location ~ \/\\.ht {\r\n deny all;\r\n }\r\n \r\n}\r\nEOF<\/pre>\n
user@vps:~# sudo ln -s \/etc\/nginx\/sites-available\/yourQ2aSite.com \/etc\/nginx\/sites-enabled\/yourQ2aSite.com<\/pre>\n
user@vps:~# sudo nginx -t\r\nuser@vps:~# sudo service nginx restart<\/pre>\n
\n