Install and setup the online survey tool LimeSurvey
published on
LimeSurvey is a versatile online survey tool which allows you to create, develop and record the responses from your own surveys.
If you want to install it on your own server, whether you are going to use Apache or NGinx, then follow the instructions below.
Install PHP 8.1 and a few other tools
sudo add-apt-repository -y ppa:ondrej/php
sudo apt update
sudo apt install php8.1-{cli, fpm, mysql, gd, soap, mbstring, bcmath, common, xml, curl, imagick, bz2, intl, zip, ldap, opcache, imap, imagick, gd, mcrypt, ssh2}
sudo apt install unzip ghostscript imagemagick
Now we need to make a few edits to two configuration files. The first can be edited by running sudo nano /etc/php/8.1/fpm/pool.d/www.conf
and making the necessary changes to the lines below (mainly uncommenting lines):
listen = /run/php/php8.1-fpm.sock
listen.owner = www-data
listen.mode = 0660
The second configuration file can be edited by running sudo nano /etc/php/8.1/fpm/php.ini and adding or editing the below lines:
expose_php = off
date.timezone = Europe/London
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=200
opcache.jit_buffer_size=100M (or other alternative if you need it)
opcache.jit=1255
Finally, restart the PHP service with sudo systemctl restart php8.1-fpm
.
Now install the MariaDB database
The following two commands will install MariaDB and tools necessary for backing databases up. The second of the commands will secure the MariaDB installation.
sudo apt-get install mariadb-server mariadb-backup
sudo mysql_secure_installation
There are two other changes which I will make to a configuration file by running sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
and making sure the two lines below appear as shown here.
bind-address = 127.0.0.1
local-infile = 0
Set up the LimeSurvey database
Enter sudo mysql -u root -p
at the command line and type the following commands at the MariaDB command prompt.
CREATE DATABASE [ls_db] charset=utf8mb4;
CREATE USER 'ls_user'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON ls_db.* to 'ls_user'@'localhost';
FLUSH PRIVILEGES;
exit
Make sure to change the database name, user name and password to something more secure.
If you are going to use the Apache web server
If you choose to use Apache the enter the following commands at the prompt.
sudo add-apt-repository -y ppa:ondrej/apache2
sudo apt update && sudo apt upgrade
sudo apt-get install apache2 apache2-utils
sudo a2enmod mime http2 rewrite deflate expires headers ssl
sudo apt-get install libapache2-mod-fcgid
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.1-fpm
sudo systemctl restart php8.1-fpm
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
If you are going to use the NGinx web server
sudo add-apt-repository -y ppa:ondrej/nginx-mainline
sudo apt update && sudo apt upgrade
sudo apt install nginx-core nginx-common nginx nginx-full libgeoip-dev libpcre3-dev
Now install LimeSurvey
Regardless of which web server you have chosen to use you can now install LimeSurvey. Do so by running the following commands where [domain]
is the domain name you will use to access your LimeSurvey installation.
sudo mkdir /var/www/[domain]
cd /tmp/
sudo wget -c https://download.limesurvey.org/latest-stable-release/limesurvey5.3.20+220615.zip
sudo unzip limesurvey5.3.20+220615.zip
sudo mv limesurvey /var/www/[domain]
sudo chown www-data:www-data -R /var/www/[domain]/
sudo chmod 755 -R /var/www/[domain]/limesurvey/
Create the web server configuration
Whether you are using Apache or NGinx you can follow the instructions below to get your web server to serve your LimeSurvey installation.
For Apache
Run sudo nano /etc/apache2/sites-available/[domain].conf
and add the following lines
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/[domain]/limesurvey
<Directory /var/www/[domain]/limesurvey>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-[domain].log
CustomLog ${APACHE_LOG_DIR}/access-[domain].log combined
<FilesMatch "\.php$">
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
</FilesMatch>
</VirtualHost>
Then run sudo a2ensite [domain].conf
and sudo systemctl restart apache2
.
For NGinx
Run sudo nano /etc/nginx/sites-available/limesurvey.conf
and add the following lines
server {
listen 80;
listen [::]:80;
server_name example.com;
root /var/www/[domain]/limesurvey;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
}
Now run sudo ln -s /etc/nginx/sites-available/limesurvey.conf /etc/nginx/sites-enabled/
and sudo systemctl restart nginx
to finish.
Secure your site with a SSL / TLS certificate
First install certbot
sudo apt install snapd
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
If you are using Apache run sudo certbot -d [domain] -d www.[domain] --apache
and if you using NGinx instead run sudo certbot -d [domain] -d www.[domain] --nginx
.
Finish off the LimeSurvey installation
Now it is time to visit your [domain]/admin to finish the installation in your browser. The default login details are:
username: admin
password: password
Final thoughts
Now that you have installed LimeSurvey you will want to get stuck in and start creating and using your own surveys. You may find the manual at https://manual.limesurvey.org/LimeSurvey_Manual will be useful to you.
Don'r forget that you may wish to adapt the virtual host or server block configuration to make LimeSurvey and your server more secure and resilient.