How to Install LimeSurvey on CentOS 7

Updated on September 8, 2016
How to Install LimeSurvey on CentOS 7 header image

LimeSurvey is a free and open source online survey tool which is widely used to publish online surveys and to collect survey feedback.

In this article, I will show you how to install LimeSurvey on a CentOS 7 server.

Prerequisites

  • A Vultr CentOS 7 server instance built from scratch.
  • A sudo user.

Step 1: Update the system to the latest stable status

sudo yum install epel-release -y
sudo yum update -y
sudo shutdown -r now

After the reboot, still log in as the same sudo user to proceed.

Step 2: Install a web server—Apache

Install Apache using YUM:

sudo yum install httpd -y

In production environment, you need to remove the pre-set Apache welcome page:

sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf

As a security measure, you should prevent Apache from exposing files and directories within the web root directory /var/www/html to visitors:

sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf

Now, start the Apache service and make it start on boot:

sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: Install PHP 5.6.x and necessary extensions

LimeSurvey requires PHP 5.3.3 or later. Since PHP 5.5 and earlier versions have reached their EOL, here, you can install PHP 5.6.x and necessary extensions using a 3rd-party YUM repo—IUS YUM repo.

First, install the IUS YUM repo:

cd
wget https://centos7.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release.rpm

Then install PHP 5.6.x and necessary extensions using the IUS YUM repo:

sudo yum install php56u php56u-common php56u-xml php56u-gd php56u-mbstring php56u-mysqlnd php56u-mcrypt php56u-imap php56u-ldap -y

Restart Apache in order to load newly installed modules:

sudo systemctl restart httpd.service

Step 4: Install MariaDB and create a database for LimeSurvey

LimeSurvey requires MySQL 5.5.3 or later. On CentOS 7, you can fulfill this request by installing MariaDB 5.5.50+ using built-in YUM repos:

sudo yum install mariadb mariadb-server -y

Start the MariaDB service and make it start on boot:

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Secure the MariaDB installation:

sudo /usr/bin/mysql_secure_installation

During the interactive process, answer questions on screen separately as below:

Enter current password for root (enter for none): Enter
Set root password? [Y/n]: Y
New password: <your-password>
Re-enter new password: <your-password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

Now, create a database for LimeSurvey:

mysql -u root -p

Use the MariaDB root password you set earlier to log in.

In the MySQL shell, by executing the following commands, you will create a database named limesurvey and a database user named limesurveyuser with the password yourpassword, and then grant all privileges on this database to this database user.

Note: On your machine, be sure to replace these parameters in each and every command with your own ones.

CREATE DATABASE limesurvey;
CREATE USER 'limesurveyuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON limesurvey.* TO 'limesurveyuser'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Step 5: Install LimeSurvey

First, download the latest stable version of LimeSurvey from the LimeSurvey official website, which is 2.51.4 at the time of writing:

cd
wget https://www.limesurvey.org/stable-release?download=1853:limesurvey2514%20160908targz -O limesurvey2.51.4.tar.gz

Unzip the archive, move everything within to the web root directory, and then grant appropriate permissions:

tar -zxvf limesurvey2.51.4.tar.gz
sudo mv limesurvey/ /var/www/html && sudo chown root:root -R /var/www/html
sudo chown -R apache:apache /var/www/html/limesurvey/tmp /var/www/html/limesurvey/upload /var/www/html/limesurvey/application/config

Modify firewall rules in order to allow web access:

sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload

Now, point your web browser to the following URL (say your server IP is 203.0.113.1), and then start the installation from there:

http://203.0.113.1/limesurvey

In the installation wizard interface:

  1. On the Welcome page, click the Start installation button.

  2. On the License page, click the I accept button.

  3. On the Pre-installation check page, confirm that all of your current settings meet LimeSurvey's requirements, and then click the Next button.

  4. On the Database configuration page, input info as below, and then click the Next button.

Note: Again, remember to replace these parameters with your own ones.

  • Database type*: MySQL
  • Database location*: localhost
  • Database user*: limesurveyuser
  • Database password: yourpassword
  • Database name*: limesurvey
  • Table prefix: lime_
  1. On the Database settings page, the wizard program will notify you that the database named limesurvey already exists. Click the Populate database button to fill in data and move on.

  2. On the Optional settings page, input info which is necessary for managing LimeSurvey. For security purposes, you should NOT use the default admin login name admin and the default masked password password. Instead, pick a lesser-known admin login name and a strong password.

  3. On the Success! page, click the Administration button to finish the installation and jump to the LimeSurvey administration page, and then use the admin login name and password you set earlier to log in:

    http://203.0.113.1/limesurvey/index.php/admin

  4. For now, you can already use LimeSurvey properly, but there still are some security tips you should be aware of.

For example, there are some sensitive info, like database username and password, stored in the LimeSurvey config file /var/www/html/limesurvey/application/config/config.php. On rare occasions, accidental errors will expose the content of this file to public.

In order to avoid this kind of security breach, you can move the original config file to a place out of the web directory, and then create a new config file to point to the original config file:

sudo cp /var/www/html/limesurvey/application/config/config.php /etc/limesurvey-config.php
sudo chown apache:apache /etc/limesurvey-config.php
echo '<?php return include("/etc/limesurvey-config.php"); ?>' | sudo tee /var/www/html/limesurvey/application/config/config.php

That concludes our tutorial. Thank you for reading.