How to Install LimeSurvey (CE) on CentOS 7

LimeSurvey is an open source survey software written in PHP. LimeSurvey source code is hosted on GitHub. In this tutorial, we will walk you through th

Linux tee Command Explained for Beginners (6 Examples)
How to Install Grafana on Linux Servers
Linux tload Command Tutorial for Beginners (with Examples)

LimeSurvey is an open source survey software written in PHP. LimeSurvey source code is hosted on GitHubIn this tutorial, we will walk you through the LimeSurvey Community Edition (CE) installation process on a fresh CentOS 7 system.

Requirements

In order to install LimeSurvey (CE) on your CentOS 7 system, make sure your system meets the following requirements:

  • Minimum 250 MB disk space.
  • MySQL 5.5.3 or later or MariaDB 5.5 or later. This tutorial will use MariaDB.
  • PHP 5.5.9 or later (PHP ۷٫۰٫۰+ is recommended) with the following extensions: Mbstring, PDO database driver for MySQL or PostgreSQL, GD-Library, IMAP, LDAP, ZIP.
  • Apache 2.4 or later or Nginx 1.1 or later. This tutorial will use Nginx.

Initial steps

Check your CentOS system version:

cat /etc/centos-release
# CentOS Linux release 7.5.1804 (Core)

Set up the timezone:

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

Update your operating system’s packages:

sudo yum update -y

Install vim, git, unzip, and socat packages:

sudo yum install -y vim git unzip socat

Step 1 – Install PHP

LimeSurvey requires PHP version ۵٫۵٫۹ or greater, while PHP 7.0.0+ is the recommended version. Default CentOS repositories contain older version of PHP, and thus we will need to set up a third-party repository to install a newer PHP version. We will use Webtatic repository.

Setup the Webtatic YUM repo:

sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Install PHP, as well as the necessary PHP extensions:

sudo yum install -y php72w php72w-cli php72w-fpm php72w-common php72w-mbstring php72w-xml php72w-mysql php72w-gd php72w-zip php72w-ldap php72w-imap

Check the PHP version:

php --version

# PHP 7.2.12 (cli) (built: Nov ۱۱ ۲۰۱۸ ۱۴:۵۴:۱۶) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Start and enable PHP-FPM service:

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

Step 2 – Install MariaDB and create a database for LimeSurvey

Install MariaDB database server:

sudo yum install -y mariadb-server

Check the MariaDB version:

mysql --version
# mysql Ver 15.1 Distrib 5.5.60-MariaDB, for Linux (x86_64) using readline 5.1

Start and enable MariaDB service:

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

Run mysql_secure installation script to improve MariaDB security and set the password for MariaDB root user:

sudo mysql_secure_installation

Answer all the questions as shown below:

Enter current password for root (enter for none):
Set root password? [Y/n]: Y
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

Log into MariaDB shell as the user root:

mysql -u root -p
# Enter password

Create a MariaDB database and user that you will use for your installation of LimeSurvey, and remember the credentials:

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;

Exit from MariaDB shell:

quit

Step 3 – Install and configure Nginx

Install Nginx webserver:

sudo yum install -y nginx

Check the NGINX version:

nginx -v
# nginx version: nginx/1.12.2

Start and enable Nginx service:

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Run sudo vim /etc/nginx/conf.d/limesurvey.conf and populate the file with the following configuration:

server {
 listen 80;

 server_name example.com;
 root /var/www/limesurvey;

 index index.php;

 location / {
 try_files $uri $uri/ /index.php?$args;
 }
 
 location ~ \.php$ {
 try_files $uri =404;
 include fastcgi_params;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 }

}

Test the NGINX configuration.

sudo nginx -t

Reload NGINX.

sudo systemctl reload nginx.service

Step 4 – Download and install LimeSuervey

Create a document root directory:

sudo mkdir -p /var/www/limesurvey

Change ownership of the /var/www/limesurvey directory to johndoe:

sudo chown -R [your_user]:[your_user] /var/www/limesurvey

Navigate to document root:

cd /var/www/limesurvey

Download the LimeSurvey ZIP installer:

wget https://www.limesurvey.org/stable-release?download=2514:limesurvey3155%20181115zip -O limesurvey.zip

Unzip LimeSurvey installer:

unzip limesurvey.zip
rm limesurvey.zip
mv limesurvey/* . && mv limesurvey/.* .
rmdir limesurvey

Change ownership of the /var/www/limesurvey directory to nginx:

sudo chown -R nginx:nginx /var/www/limesurvey

Create the directory/var/lib/php/session and set ownership to nginx.

sudo mkdir -p /var/lib/php/session && sudo chown -R nginx:nginx /var/lib/php

Run sudo vim /etc/php-fpm.d/www.conf and set the user and group to nginx. Initially, they will be set to apache:

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

Restart the PHP-FPM service:

sudo systemctl restart php-fpm.service

Step 5 – Complete the LimeSurvey setup

Open your web browser and type the URL http://example.com. You will be redirected to the following page:

LimeSurvey Installer

Select your preferred language and click on the Start Installation button. AfterThe LimeSurvey license page should appear.

Accept the license

Check and click on the I accept button if you agree with the license terms. After this step, you should see the LimeSurvey pre-installation check page:

pre-installation check

Make sure all the requirements are completed, then click on the Next button. This should direct you to the database configuration page.

Database configuration

Enter the database settings you want to use for LimeSurvey and click on the Next button.  You should see the following page:

Database settings

Click on the Populate database button. You should see the following page:

Administration settings

Here, provide your admin username and password, site name, email address, then click on the Next button. Once the installation has been completed, you should see the following page:

LimeSurvey installed successfully

Now, click on the Administration button. You should see the following page:

Log-in

Provide your login details, then click on the Log In button. You should see the LimeSurvey administration interface:

Lime Survey Dashboard

Links