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/phpsudo apt updatesudo 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.socklisten.owner = www-datalisten.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 = offdate.timezone = Europe/Londonopcache.enable=1opcache.memory_consumption=128opcache.max_accelerated_files=10000opcache.revalidate_freq=200opcache.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-backupsudo 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.1local-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/apache2sudo apt update && sudo apt upgradesudo apt-get install apache2 apache2-utilssudo a2enmod mime http2 rewrite deflate expires headers sslsudo apt-get install libapache2-mod-fcgidsudo a2enmod proxy_fcgi setenvifsudo a2enconf php8.1-fpmsudo systemctl restart php8.1-fpmsudo a2dissite 000-default.confsudo systemctl restart apache2
If you are going to use the NGinx web server
sudo add-apt-repository -y ppa:ondrej/nginx-mainlinesudo apt update && sudo apt upgradesudo 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.zipsudo unzip limesurvey5.3.20+220615.zipsudo 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 snapdsudo snap install core; sudo snap refresh coresudo snap install --classic certbotsudo 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: adminpassword: 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.
