[How-To] Create a LimeSurvey Iocage Jail

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
freebsd-limesurvey-jail.jpg


INTRODUCTION

Before we begin, I'm really no expert when it comes to this stuff, so most of what I've 'learnt' to put together this guide has come from other threads on this forum (e.g. here) and from Google searches. If you attempt this and it doesn't work, I may not be able to help you troubleshoot very far, so be warned!

LimeSurvey, as the name would suggest, is an open-source online survey tool which can be used to create some really great surveys. Think of it as your own SurveyMonkey without any of the limitations that you might get trying to use the free version. It probably takes a little more time to get your head around the user interface, but once you have I'd say it was even more powerful and much more customisable.

I've built and run a number of surveys on mine, although the first jail I built was using a 11.1-RELEASE template that just wouldn't upgrade to 11.3. That gave me a perfect opportunity to rebuild it and document the process, hence this guide :)

INSTALLATION

CONFIGURATION

CHANGES
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
INSTALLATION

Create iocage jail


I think it's easier to do this in a WUI now, so here's a screenshot of my settings:

jail-settings.jpg


You can also do it from the CLI, ideally using SSH so you can copy and paste commands across.

Code:
iocage create --name '<JAIL_NAME>' -r 13.1-RELEASE ip4_addr='vnet0|<JAIL_IP>/24' defaultrouter='<IPV4_DEFAULT_GATEWAY>'
vnet='on' allow_raw_sockets='1' boot='on'

Replace:

<JAIL_NAME> with the name you want the iocage jail to have (I have used 'limesurvey')
<JAIL_IP> with the IP address you want the jail to have, within a useable range
<IPV4_DEFAULT_GATEWAY> with the value in Network > Global Configuration

Console into jail

Code:
iocage console limesurvey


Install packages

It's probably worth updating the jail before you start

Code:
pkg update
pkg upgrade


Code:
pkg install mariadb103-server

pkg install php74 php74-mbstring php74-pdo php74-session php74-openssl php74-fileinfo php74-pdo_mysql php74-imap
php74-gd php74-zip php74-zlib mod_php74 php74-mysqli php74-extensions php74-pecl-APCu  php74-bcmath php74-bz2 php74-calendar
php74-curl php74-dba php74-exif php74-ftp php74-gettext php74-mysqli php74-mbstring php74-ldap

pkg install apache24 (installed as PHP dependency above)

pkg install nano (I find this much easier than vi or ee)

Enable services in rc.conf

Code:
sysrc 'apache24_enable=YES' 'php_fpm_enable=YES' 'mysql_enable=YES'

Configure PHP

Code:
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

nano /usr/local/etc/php.ini

edit: cgi.fix_pathinfo=0
edit: date.timezone = Europe/London
add: apc.enable_cli=1

Code:
nano /usr/local/etc/php-fpm.d/www.conf

enable: listen = /var/run/php-fpm.sock
enable: listen.owner = www
enable: listen.group = www
enable: env[PATH] = /usr/local/bin:/usr/bin:/bin

Configure MySQL

Code:
nano /usr/local/etc/my.cnf


[server]
skip-networking
skip-name-resolve
expire_logs_days = 1
innodb_flush_method = O_DIRECT
skip-innodb_doublewrite
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table

Start services and configure MySQL

Code:
service apache24 start && service php-fpm start && service mysql-server start

mysql -e "CREATE DATABASE limesurvey;"

mysql -e "GRANT ALL PRIVILEGES ON limesurvey.* TO 'lsuser'@'localhost' IDENTIFIED
BY 'lspass';"

mysql -e "FLUSH PRIVILEGES;"

mysql_secure_installation

Download LimeSurvey

Right, I'm sure there is a much better way of doing this, but I downloaded from here and saved to a temp folder I have mounted on my pool (e.g. /mnt/pool/temp/). I uncompressed the download, which created a limesurvey folder. I then mounted the temp folder on my pool to the /temp folder inside the jail and moved it to the correct location for apache. Feel free to do this in a much better way :D

Still inside the jail

Code:
mkdir /temp

exit

From the FreeNAS CLI

Code:
iocage fstab -a limesurvey '/mnt/pool/temp/ /temp nullfs rw 0 0'

iocage console limesurvey

cd /temp

mv limesurvey /usr/local/www/apache24/

cd /usr/local/www/apache24

rm -rf data
mv limesurvey data

chown -R www:www /usr/local/www/apache24/data

Are you still with me, as we're almost there!

Apache configuration

Code:
nano /usr/local/etc/apache24/httpd.conf

enable: LoadModule php7_module libexec/apache24/libphp7.so
add: AddType application/x-httpd-php .php (on line below the one enabled above)
add: index.php into <IfModule dir_module> DirectoryIndex index.php index.html</IfModule>
add: after the <Files> section
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>

Restart Apache

Code:
apachectl graceful

In theory, if you browser to the <JAIL_IP> you specified right at the beginning when creating the iocage jail, you should see the LimeSurvey configuration screen.
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
CONFIGURATION

If you've made it this far, I suspect you don't need any help working through the LimeSurvey setup wizard, but just in case!

You'll need the limesuvey user, password and database names used at this step:

Start services and configure mysql

Code:
mysql -e "CREATE DATABASE limesurvey;"

mysql -e "GRANT ALL PRIVILEGES ON limesurvey.* TO 'lsuser'@'localhost' IDENTIFIED
BY 'lspass';"

So:

Username = lsuser
Password = lspass
Database = limesurvey

You'll can also change the default Admin user password, add an e-mail address and even change the site name if you want!

Other configuration

You should end up with a LimeSurvey login screen, or if not go to http://<JAIL_IP>/admin

The default password if you didn't change it is password :D

Here's a link to the manual pages describing the installation and configuration. Much of this is based around that.

Lastly, if you are thinking of using this externally, I'd recommend a domain name and another jail configured as an NGINX reverse proxy with Letsencrypt for SSL certificates to protect it, although that's a whole different "How-To" guide, but if you search the forum you'll probably find something that would help ;)

Good luck and happy surveying...
 
Last edited:

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
CHANGES

This is only my 2nd attempt at a [How-To] guide, so please be gentle!

I'll make a note of any changes made here:


18-July-2022 - Updated instructions for a jail based on 13.1-RELEASE (PHP7.3 unsupported) although still keeping mariadb and PHP quite old so I can use the same database. Will look to update these once I have it working in the new jail.
 
Last edited:
Top