Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.
Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

[How-To] Create a LimeSurvey Iocage Jail

adrianwi

Neophyte Sage
Joined
Oct 15, 2013
Messages
1,102
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

Neophyte Sage
Joined
Oct 15, 2013
Messages
1,102
INSTALLATION

You could do some of this from the WUI, although this is all going to be from the CLI, ideally using SSH so you can copy and paste commands across.

Create iocage jail

Code:
iocage create --name '<JAIL_NAME>' -r 11.3-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

Code:
pkg install mariadb103-server

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

pkg install apache24

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

Create my.cnf file

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

Neophyte Sage
Joined
Oct 15, 2013
Messages
1,102
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 = lcuser
Password = lcpass
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

Neophyte Sage
Joined
Oct 15, 2013
Messages
1,102
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:
 
Last edited:
Top